Skip to content

fix(e2e-harnesses): loosen codex 401 assertion to drop third-party error body text - #329

Merged
omridevk merged 1 commit into
mainfrom
fix/codex-401-assertion-drift
Aug 8, 2026
Merged

fix(e2e-harnesses): loosen codex 401 assertion to drop third-party error body text#329
omridevk merged 1 commit into
mainfrom
fix/codex-401-assertion-drift

Conversation

@omridevk

@omridevk omridevk commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closes #328.

e2e/harnesses/tests/harnesses.spec.ts asserted OpenAI's full 401 error body. OpenAI reworded it, so the assertion broke on text we don't own — red on e2e consumer apps (shard-3) every run, blocking release PR #324 (tracked in #327).

-/^Reconnecting\.\.\. \d+\/\d+ \(unexpected status 401 Unauthorized: Missing bearer or basic authentication in header, url: wss:\/\/api\.openai\.com\/v1\/responses/m
+/^Reconnecting\.\.\. \d+\/\d+ \(unexpected status 401 Unauthorized: .*url: wss:\/\/api\.openai\.com\/v1\/responses/m

Keeps what's ours to assert — the reconnect banner shape, the 401 Unauthorized status, and the OpenAI responses host. Drops the body text and the trailing cf-ray. It has to match both wordings, since we don't control which one comes back:

old body matches: true
new body matches: true
500 does NOT match: false
different host does NOT match: false
success does NOT match: false

A finding worth recording

I ran playwright test --project=codex locally to get failing-first proof. It failed — but not on the 401:

Expected pattern: /^Reconnecting\.\.\. \d+\/\d+ \(unexpected status 401 Unauthorized: Missing bearer …
Received string:  "Hi!"

The dev machine has a real codex login (codex login status → "Logged in using ChatGPT", plus OPENAI_API_KEY in the env), so codex authenticates and returns a normal reply.

This test can never pass locally on an authenticated machine, on either the old or the new pattern — it asserts an error banner, and a logged-in codex answers the prompt. It's implicitly CI-shaped, since CI has no codex credentials. Worth knowing before anyone else burns time trying to reproduce a harness failure locally.

Forcing an unauthenticated state with an empty CODEX_HOME produced thread/resume failed: no rollout found for thread id … instead, never reaching the WebSocket handshake. That's the expected consequence of pointing the CLI at an empty home while a session references a rollout in the real one — classified as an artifact of the forced state, not filed as a bug.

Gates

typecheck (conciv-e2e-harnesses) pass; pnpm lint 0 errors; fallow audit verdict pass, 0 introduced. The one format:check failure is packages/ui-kit-chat/CHANGELOG.md, which fails on main too — last touched by 4fe834d0 chore: version packages (#317), unrelated to this diff.

No changeset: e2e/harnesses is private: true, not a published package.

CI is the real gate here, which is fitting — CI is where it's currently red.

🤖 Generated with Claude Code

…ror body text

The outcomePattern for codex pinned OpenAI's full 401 body ("Missing
bearer or basic authentication in header") plus the cf-ray tail, both
of which we don't own and which OpenAI changed, breaking the assertion
on every CI run and blocking #324 (tracked in #327).

The regex now keeps only what's ours to assert: the "Reconnecting...
N/M" banner shape, "unexpected status 401 Unauthorized", and the
wss://api.openai.com/v1/responses URL.

Note the 401 path is unreachable on a machine with a real codex login
(an authenticated run gets a normal reply instead of the reconnect
banner), so this can only be proven end-to-end in CI, which runs
without credentials.

Fixes #328

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@omridevk
omridevk merged commit c63a7c7 into main Aug 8, 2026
40 of 41 checks passed
@omridevk
omridevk deleted the fix/codex-401-assertion-drift branch August 8, 2026 10:27
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.

e2e harnesses: codex 401 assertion pins OpenAI's error body text — drifted, blocks CI

1 participant