Skip to content

fix(web): read the status of a recorded response in the hook dry run - #887

Open
thecorporatetractor wants to merge 2 commits into
BaaRai:mainfrom
thecorporatetractor:fix/tamper-hooks-recorded-status
Open

thecorporatetractor wants to merge 2 commits into
BaaRai:mainfrom
thecorporatetractor:fix/tamper-hooks-recorded-status

Conversation

@thecorporatetractor

@thecorporatetractor thecorporatetractor commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Traffic › Hooks › dry run from a recorded exchange uses status 200 for the response, whatever the recorded status was (WebSocket upgrades, stored as HTTP/1.1 101, were already parsed).

The recorder stores the response head as HTTP <status> with no version (traffic/traffic.go:778, traffic/stream.go:317, traffic/external.go:57). parseRawResponse (web/src/lib/tamper-hooks.ts) requires HTTP/<version> <status>, so the match always fails and it falls back to 200. A hook that branches on the status, such as one that only rewrites 404 responses, behaves differently in the dry run than on live traffic.

Behavior change

The version is optional: HTTP 404 gives 404. A full HTTP/1.1 404 line still parses the same way. StartLine in web/src/components/http-code-block.tsx had the same pattern, so recorded responses showed no status colour on the traffic, replay and evidence views; it gets the same fix.

Tested

New case in web/scripts/tamper-hooks.test.mjs: HTTP 404\nContent-Type: text/plain\n\nnot found gives status 404, its header and its body. It fails before the change. npm run test:tamper-hooks, tsc --noEmit and Biome pass.

The traffic recorder stores the response head as "HTTP <status>" with no
version (traffic/traffic.go, stream.go, external.go). parseRawResponse
required "HTTP/<version> <status>", so the match always failed and a dry
run from a recorded exchange used status 200, whatever the response was.
Make the version optional.
StartLine in http-code-block.tsx had the same HTTP/<version> pattern, so
recorded responses ("HTTP <status>") on the traffic, replay and evidence
views showed no status colour. Make the version optional there too.
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