Skip to content

fix(test): reset recording proxy between 502 retries to fix telemetry flake - #327

Merged
leggetter merged 1 commit into
mainfrom
fix/acceptance-telemetry-502-retry-flake
Aug 5, 2026
Merged

fix(test): reset recording proxy between 502 retries to fix telemetry flake#327
leggetter merged 1 commit into
mainfrom
fix/acceptance-telemetry-502-retry-flake

Conversation

@leggetter

Copy link
Copy Markdown
Collaborator

Summary

Fixes the acceptance-telemetry flakiness tracked in #326 (task 1) — the prerequisite for gating releases on acceptance tests.

Root cause

The harness already retries transient API 502/500s (runWithHTTP502Retry). But a retry re-runs the whole CLI command, which emits a new invocation_id. The RecordingProxy kept the failed attempt's requests alongside the successful retry's, so AssertTelemetryConsistent saw two different invocation_ids and failed. This is what took down the acceptance-telemetry job during the v2.3.2 release window.

Fix

  • runWithHTTP502Retry now resets the recording proxy referenced by --api-base before each retry, so only the final (successful) attempt's requests remain — preserving the strict "one invocation_id per run" assertion.
  • Proxies self-register by URL (StartRecordingProxy registers, Close deregisters), so none of the 64 call sites change and no future test can forget to wire it up.
  • The reset only fires on an actual retry, so there's no behavior change for the common (no-502) path.

Test

Adds TestRunWithHTTP502RetryResetsRecordingProxy — a deterministic regression test using a fake upstream and a simulated 502→success, so it validates the fix without a live API and never flakes. Passes locally under -tags=telemetry.

Part of #326.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UQV9qtvETd62qg2iDRR6kY

… flake

The acceptance-telemetry job flaked when a transient API 502 triggered a CLI-command retry: the recording proxy kept the failed attempt's requests (one invocation_id) alongside the successful retry's (a different invocation_id), so AssertTelemetryConsistent saw two invocation_ids and failed. runWithHTTP502Retry now resets the proxy referenced by --api-base before each retry, so only the final attempt's requests remain. Proxies self-register by URL, so no per-test wiring is needed and the reset only fires on an actual retry. Adds a deterministic regression test (fake upstream + simulated 502). Part of #326.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UQV9qtvETd62qg2iDRR6kY
@leggetter
leggetter merged commit 4e0102f into main Aug 5, 2026
12 checks passed
@leggetter
leggetter deleted the fix/acceptance-telemetry-502-retry-flake branch August 5, 2026 11:43
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.

1 participant