From 7692dd497535942eccd9d707cfbd0f36e9704f75 Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 4 May 2026 15:08:37 -0700 Subject: [PATCH] fix(synth-e2e): correct curl status-code parse in 7c gate The first version of the config.yaml round-trip gate (PR #2773) captured curl output with `-w '\n%{http_code}\n'` and parsed via `tail -n 2 | head -n 1`. That broke because bash's $(...) strips the trailing newline, leaving only 2 lines in the captured value: line 1: line 2: `tail -n 2 | head -n 1` then returned line 1 (the body), not the status code. The gate misreported 200-with-JSON-body responses as "PUT returned " and failed the canary post-merge at 22:06 UTC. Fix: write body to a tempfile via `-o "$PUT_TMP"` and use `-w '%{http_code}'` as the sole stdout. Status code is now unambiguously the captured value, body is read separately from the tempfile. No newline-counting heuristic needed. Verification: - bash -n clean - shellcheck clean on the modified block - Will be exercised by the next continuous-synth-e2e firing Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/e2e/test_staging_full_saas.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/e2e/test_staging_full_saas.sh b/tests/e2e/test_staging_full_saas.sh index cffd5b42..8c5cf472 100755 --- a/tests/e2e/test_staging_full_saas.sh +++ b/tests/e2e/test_staging_full_saas.sh @@ -530,13 +530,22 @@ runtime: ${RUNTIME} " for wid in $WS_TO_CHECK; do PUT_BODY=$(python3 -c "import json,sys; print(json.dumps({'content': sys.stdin.read()}))" <<< "$CONFIG_PAYLOAD") - PUT_RESP=$(tenant_call PUT "/workspaces/$wid/files/config.yaml" \ + # Capture body to a tempfile so curl's -w '%{http_code}' is the only + # thing on stdout. The first version used `-w '\n%{http_code}\n'` and + # parsed via `tail -n 2 | head -n 1`, which broke because bash $(...) + # strips the trailing newline → only 2 lines remain in the captured + # value → head -n 1 returned the body, not the status code. Caught + # post-merge by E2E Staging SaaS at 22:06 UTC: a 200-with-body got + # misreported as "PUT returned ". + PUT_TMP=$(mktemp -t synth_put.XXXXXX) + PUT_CODE=$(tenant_call PUT "/workspaces/$wid/files/config.yaml" \ -H "Content-Type: application/json" \ -d "$PUT_BODY" \ - -w $'\n%{http_code}\n' \ - 2>/dev/null || printf '\n500\n') - PUT_CODE=$(echo "$PUT_RESP" | tail -n 2 | head -n 1) - PUT_BODY_OUT=$(echo "$PUT_RESP" | sed '$d' | sed '$d') + -o "$PUT_TMP" \ + -w '%{http_code}' \ + 2>/dev/null || echo "000") + PUT_BODY_OUT=$(cat "$PUT_TMP" 2>/dev/null || echo "") + rm -f "$PUT_TMP" if [ "$PUT_CODE" != "200" ] && [ "$PUT_CODE" != "204" ]; then fail "Workspace $wid Files API PUT config.yaml returned $PUT_CODE: $PUT_BODY_OUT — likely a path-map or permission regression in workspace-server template_files_eic.go" fi