diff --git a/tests/e2e/test_staging_external_runtime.sh b/tests/e2e/test_staging_external_runtime.sh index 9e73228c8..b44879957 100755 --- a/tests/e2e/test_staging_external_runtime.sh +++ b/tests/e2e/test_staging_external_runtime.sh @@ -238,10 +238,17 @@ admin_call() { # ─── 1. Create org ────────────────────────────────────────────────────── log "1/8 Creating org $SLUG..." +# admin_call inherits CURL_COMMON's --fail-with-body: a non-2xx makes curl +# exit 22, which under `set -euo pipefail` would abort this bare command +# substitution BEFORE the `fail "... missing 'id'"` handler below can print +# the body. set +e / `|| true` keeps the 22 from tripping `set -e`; curl +# still wrote the body, so CREATE_RESP holds it and the id-check surfaces why. +set +e CREATE_RESP=$(admin_call POST /cp/admin/orgs \ -d "{\"slug\":\"$SLUG\",\"name\":\"E2E ext $SLUG\",\"owner_user_id\":\"e2e-runner:$SLUG\"}") -ORG_ID=$(echo "$CREATE_RESP" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))") -[ -z "$ORG_ID" ] && fail "Org create response missing 'id'" +set -e +ORG_ID=$(echo "$CREATE_RESP" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || echo "") +[ -z "$ORG_ID" ] && fail "Org create response missing 'id': $(printf '%s' "$CREATE_RESP" | sanitize_http_body 2>/dev/null || printf '%s' "$CREATE_RESP")" ok "Org created (id=$ORG_ID)" # ─── 2. Wait for tenant provisioning ──────────────────────────────────── @@ -334,8 +341,13 @@ tenant_call() { # on whatever the create handler set first (typically 'provisioning') # because the follow-up UPDATE failed the enum cast. log "4/8 Creating external workspace (no URL — exercises workspace.go:333)..." +# tenant_call inherits CURL_COMMON's --fail-with-body: guard the same way as +# the org create above so a non-2xx returns the body to the id/status checks +# below instead of aborting opaquely on curl exit 22. +set +e WS_CREATE_RESP=$(tenant_call POST /workspaces \ -d '{"name":"ext-e2e","runtime":"external","external":true}') +set -e WS_ID=$(echo "$WS_CREATE_RESP" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))") WS_RESP_STATUS=$(echo "$WS_CREATE_RESP" | python3 -c "import json,sys; print(json.load(sys.stdin).get('status',''))") @@ -348,7 +360,7 @@ try: except Exception: print('') ") -[ -z "$WS_ID" ] && fail "Workspace create missing id: $WS_CREATE_RESP" +[ -z "$WS_ID" ] && fail "Workspace create missing id: $(printf '%s' "$WS_CREATE_RESP" | sanitize_http_body 2>/dev/null || printf '%s' "$WS_CREATE_RESP")" [ "$WS_RESP_STATUS" != "awaiting_agent" ] && fail "Expected response status=awaiting_agent, got $WS_RESP_STATUS" ok "Workspace created (id=$WS_ID, response status=awaiting_agent)" diff --git a/tests/e2e/test_staging_full_saas.sh b/tests/e2e/test_staging_full_saas.sh index 670d1308f..862b468a2 100755 --- a/tests/e2e/test_staging_full_saas.sh +++ b/tests/e2e/test_staging_full_saas.sh @@ -710,9 +710,21 @@ if [ -n "$PROVISION_TEMPLATE" ]; then else log "5/11 Provisioning parent workspace (runtime=$RUNTIME)..." fi +# tenant_call inherits CURL_COMMON's --fail-with-body, so a non-2xx create +# (e.g. the 422 RUNTIME_UNSUPPORTED below) makes curl exit 22. Capturing it +# bare as $(tenant_call ...) propagates that 22 through the command +# substitution and, under `set -euo pipefail`, ABORTS the whole script right +# here — before the `fail "... Response: ..."` handler below can print the +# body. The result was an opaque `curl: (22) ... error: 422` + teardown with +# no body (run 220702, main f78fef4c, step "5/11 Provisioning parent +# workspace"). set +e / `|| true` keeps the 22 from tripping `set -e`; curl +# still WROTE the body to stdout (that's what --fail-with-body does), so +# PARENT_RESP holds the 422 JSON and the id-check below surfaces WHY. +set +e PARENT_RESP=$(tenant_call POST /workspaces \ -H "Content-Type: application/json" \ -d "$(build_create_payload 'E2E Parent')") +set -e # Surface the workspace-create error CLEARLY instead of dying on a Python # KeyError when the response has no 'id'. The load-bearing cases this names: # - google-adk: RUNTIME_UNSUPPORTED 422 if google-adk is absent from the @@ -733,9 +745,14 @@ log " PARENT_ID=$PARENT_ID" CHILD_ID="" if [ "$MODE" = "full" ]; then log "6/11 Provisioning child workspace..." + # Same --fail-with-body / set -e abort guard as the parent create above: + # let a non-2xx return the body so the id-check below surfaces it instead + # of the script dying opaquely on curl exit 22. + set +e CHILD_RESP=$(tenant_call POST /workspaces \ -H "Content-Type: application/json" \ -d "$(build_create_payload 'E2E Child' "$PARENT_ID")") + set -e CHILD_ID=$(echo "$CHILD_RESP" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || echo "") if [ -z "$CHILD_ID" ]; then fail "Child workspace create returned no 'id' (runtime=$RUNTIME, template=${PROVISION_TEMPLATE:-}). Response: $(printf '%s' "$CHILD_RESP" | sanitize_http_body)"