Skip to content

Correlate browser e2e /run logs via X-Test-ID - #317

Merged
mxschmitt merged 3 commits into
mainfrom
cursor/e2e-log-correlation-7b47
Sep 3, 2026
Merged

mxschmitt merged 3 commits into
mainfrom
cursor/e2e-log-correlation-7b47

Conversation

@mxschmitt

@mxschmitt mxschmitt commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Why

CI visual e2e flakes (Turnstile / Firefox /run hangs) had empty aggregator attachments. The aggregator keys logs by testId. Browser tests never sent Playwright’s test id, so control stored logs under a uuid the report did not look up — and if /run never returned, attachment never ran.

This PR does not change who mints requestId. Client-facing testId is only X-Test-ID. Control copies that onto the worker job JSON. Do not use page.setExtraHTTPHeaders (Firefox then fails fetch('/service/control/run')).

Who invents the IDs

requestId — unchanged

Control always does uuid.New() in handleRun and overwrites req.RequestID. Incoming X-Request-ID and JSON requestId are ignored.

testId — before vs after

Caller Before After
Production UI Control uuid (no header) Same
Visual e2e Control uuid. Attach used payload.testId after /run returned; a hang attached nothing Playwright test.info().testId via addInitScriptX-Test-ID on the runCode fetch. Attach in finally. Init script is on the page fixture (all visual tests, not only executeExample)
API e2e Header and JSON testId Header only
Nothing sent Control uuid Control uuid

Playwright’s testId is not a uuid.New() string. Control’s fallback is.

JSON testId on the /run body is ignored. It remains on the AMQP worker payload after control copies the header.

Code

  • control-service: testID = X-Test-ID else request uuid; overwrite req.TestID
  • frontend/src/utils.ts: runCode sets X-Test-ID when window.__TRY_PLAYWRIGHT_TEST_ID__ is set (production never sets it)
  • e2e/tests/logAggregator.ts: installE2ETestId + attachAggregatorLogs
  • Visual: init script on the page fixture; attach in finally
  • API tests: X-Test-ID only

Test plan

  • go test ./control-service/
  • TestHandleRunPostsAggregatorLogsUnderHeaderTestID: POST /run with X-Test-ID=pw-id and JSON testId=from-body, no workers (10s hang). Asserts 503, response testId is pw-id, aggregator has control lines under pw-id, and from-body is empty.

Validation

No k3s here. The httptest is the hung /run case. Passed locally (go test ./control-service/).

Open in Web Open in Cursor 

Visual tests never sent Playwright's test id, so aggregator attachments
used a random control uuid and were empty when /run hung. API tests
already send testId in the body; control logged the header/uuid instead
when those differed.

Prefer JSON testId over X-Test-ID (Firefox fetch breaks if the page
sets extra headers). Browser tests inject the id with addInitScript
and attach aggregator logs in finally, including failed waits.

Co-authored-by: Max Schmitt <max@schmitt.mx>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T01:53:48.091557Z c2cd001 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

cursoragent and others added 2 commits September 3, 2026 02:30
Reproduce the visual e2e hang: JSON Playwright testId plus a different
X-Test-ID, no workers available. Aggregator must store control logs
under the body id, not the header.

Co-authored-by: Max Schmitt <max@schmitt.mx>
Clients send Playwright's test id on the request header, not in JSON.
Control overwrites the worker payload from that header (or the request
uuid). runCode sets X-Test-ID on the fetch; do not use extra page headers.

Co-authored-by: Max Schmitt <max@schmitt.mx>
@cursor cursor Bot changed the title Correlate browser e2e /run logs via JSON testId Correlate browser e2e /run logs via X-Test-ID Sep 3, 2026
@mxschmitt
mxschmitt merged commit 960ad9e into main Sep 3, 2026
12 checks passed
@mxschmitt
mxschmitt deleted the cursor/e2e-log-correlation-7b47 branch September 3, 2026 19:09
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.

2 participants