From 1ce51abea4d121810ba9287bb0d60ec45fe237de Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 4 May 2026 16:46:35 -0700 Subject: [PATCH] =?UTF-8?q?fix(synth-e2e):=20correct=20=C2=A79c=20stale-40?= =?UTF-8?q?9=20capture=20=E2=80=94=20curl=20exit=20code=20polluted=20statu?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The §9c "Memory KV Edit round-trip" gate (added in #2787) captured the expected-409 status code via: $(tenant_call ... -w "%{http_code}" || echo "000") tenant_call uses CURL_COMMON which carries --fail-with-body. On the expected 409, curl exits 22; the `|| echo "000"` then fires and appends "000" to the captured stdout — yielding "409000" instead of "409", failing the gate even though the contract was satisfied. Caught on PR #2792's first E2E run (status got "409000"). Has been silently failing the staging-SaaS E2E since #2787 merged earlier today; nothing else surfaced it because the workflow is informational, not required. Fix: route -w into its own tempfile so curl's exit code can't pollute the captured stdout. Wrap with set +e/-e so the 22 doesn't trip the outer pipeline. Same shape as the §7c gate fix that PR #2779/#2783 landed for the same class of bug. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/e2e/test_staging_full_saas.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/e2e/test_staging_full_saas.sh b/tests/e2e/test_staging_full_saas.sh index e5f40b70..2caece5c 100755 --- a/tests/e2e/test_staging_full_saas.sh +++ b/tests/e2e/test_staging_full_saas.sh @@ -742,11 +742,24 @@ print(len(d if isinstance(d, list) else d.get('events', [])))" 2>/dev/null || ec [ "$EDIT_VAL2" = "2" ] || fail "memory KV Edit did not persist new value. Body: ${EDIT_GET2:0:200}" # 5. stale-version POST must 409 — pin the optimistic-lock contract. - EDIT_STALE_CODE=$(tenant_call POST "/workspaces/$PARENT_ID/memory" \ + # + # tenant_call uses CURL_COMMON which carries --fail-with-body, so an + # expected-409 makes curl exit 22. The previous shape + # $(tenant_call ... -w "%{http_code}" || echo "000") + # concatenated the captured "409" with the fallback "000" giving a + # bogus "409000" value (caught on PR #2792's first E2E run, which is + # also why staging-saas E2E has been silent-failing this gate since + # PR #2787 merged). Fix: route the status code into its own tempfile + # so curl's exit code can't pollute the captured stdout. set +e/-e + # keeps the 22 from tripping the outer `set -e` pipeline. + set +e + tenant_call POST "/workspaces/$PARENT_ID/memory" \ -H "Content-Type: application/json" \ -d "{\"key\":\"$EDIT_KEY\",\"value\":{\"step\":3},\"if_match_version\":$EDIT_VER}" \ - -o /tmp/memory_stale_resp.txt -w "%{http_code}" 2>/dev/null || echo "000") - [ "$EDIT_STALE_CODE" = "409" ] || fail "memory KV stale Edit must 409 (optimistic-lock). Got $EDIT_STALE_CODE: $(cat /tmp/memory_stale_resp.txt 2>/dev/null | head -c 200)" + -o /tmp/memory_stale_resp.txt -w "%{http_code}" >/tmp/memory_stale_code.txt 2>/dev/null + set -e + EDIT_STALE_CODE=$(cat /tmp/memory_stale_code.txt 2>/dev/null || echo "000") + [ "$EDIT_STALE_CODE" = "409" ] || fail "memory KV stale Edit must 409 (optimistic-lock). Got '$EDIT_STALE_CODE': $(cat /tmp/memory_stale_resp.txt 2>/dev/null | head -c 200)" # cleanup tenant_call DELETE "/workspaces/$PARENT_ID/memory/$EDIT_KEY" >/dev/null 2>&1 || true