Skip to content

fix(demo): resolve dynamic BASE_URL and handle silent curl failures (#87) - #115

Open
HamidKhan1001 wants to merge 1 commit into
drasi-project:mainfrom
HamidKhan1001:fix/demo-scripts-base-url-and-retry
Open

fix(demo): resolve dynamic BASE_URL and handle silent curl failures (#87)#115
HamidKhan1001 wants to merge 1 commit into
drasi-project:mainfrom
HamidKhan1001:fix/demo-scripts-base-url-and-retry

Conversation

@HamidKhan1001

@HamidKhan1001 HamidKhan1001 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Fixes demo script execution failures on local k3d clusters where Traefik port mapping differs from Codespaces default port bindings. Also standardizes curl retry behavior to catch connection failures (HTTP 000) and non-2xx responses instead of reporting false successes.

Changes

  • Dynamic BASE_URL Resolution: Implemented a fallback chain (ENV -> Codespaces -> docker port k3d-drasi-tutorial-serverlb 80 -> default http://localhost:8123) across demo-catalogue-service.sh, demo-dashboard-service.sh, and demo-notifications-service.sh.
  • Robust HTTP Status Verification: Updated execute_with_retry in demo-dashboard-service.sh and demo-notifications-service.sh to extract the HTTP status code using curl -w "\n%{http_code}". Non-2xx responses and 000 status codes are now correctly identified as retriable errors.

Fixes #87

Copilot AI review requested due to automatic review settings July 23, 2026 07:46
@HamidKhan1001
HamidKhan1001 requested a review from a team as a code owner July 23, 2026 07:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes local execution of the Dapr demo scripts by dynamically determining the correct Traefik load balancer port (instead of assuming http://localhost) and by making the retry wrapper treat non-2xx/connection-failure responses as failures rather than reporting false successes.

Changes:

  • Add a BASE_URL fallback chain that detects Codespaces vs local k3d and derives the mapped Traefik port via Docker inspection.
  • Update execute_with_retry (dashboard + notifications demos) to verify success via extracted HTTP status codes rather than only shell exit codes / output heuristics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tutorial/dapr/demo/demo-notifications-service.sh Adds dynamic BASE_URL resolution and changes retry logic to validate HTTP status codes.
tutorial/dapr/demo/demo-dashboard-service.sh Adds dynamic BASE_URL resolution and changes retry logic to validate HTTP status codes.
tutorial/dapr/demo/demo-catalogue-service.sh Adds dynamic BASE_URL resolution to work on local k3d port mappings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if [ -z "$BASE_URL" ]; then
if [ -n "$CODESPACES" ]; then
BASE_URL="http://localhost"
elif command -v docker >/dev/null 2>&1 && docker inspect k3d-drasi-tutorial-serverlb >/dev/null 2>&1; then
BASE_URL="http://localhost"
elif command -v docker >/dev/null 2>&1 && docker inspect k3d-drasi-tutorial-serverlb >/dev/null 2>&1; then
PORT=$(docker port k3d-drasi-tutorial-serverlb 80 2>/dev/null | head -n1 | cut -d: -f2)
if [ -n "$PORT" ]; then
if [ -n "$CODESPACES" ]; then
BASE_URL="http://localhost"
elif command -v docker >/dev/null 2>&1 && docker inspect k3d-drasi-tutorial-serverlb >/dev/null 2>&1; then
PORT=$(docker port k3d-drasi-tutorial-serverlb 80 2>/dev/null | head -n1 | cut -d: -f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Demo scripts fail with HTTP 000 on local machines: hardcoded BASE_URL and silent curl failures"

4 participants