fix(assert): Render header values readably; document multi-value - #101
Merged
Conversation
A failed header assertion printed Go's slice syntax at the user: a header that only ever carried one value came back as `got ["abc123"]`, which reads as though something bracketed had happened to it. Values are now written the way a person writes them -- `got "abc123"` for one, `got "first", "second"` for several. The bracket was the only place the tool admitted that a header is a list. --assert-header and --assert-header-eq hold when ANY value matches, so --assert-header-eq 'Set-Cookie: session=abc' passes against a response setting three cookies. That is the right default and is not changing, but "equals" and the README's "exact value" both read as a claim about the only value, and nothing in --help or the README mentioned multiple values at all. Both now say so, next to the paragraph about repeating the flag, which is a different thing and was the only nearby text a reader could mistake for this one. The rendering was wrong in three assertions rather than the one reported: --assert-header and --assert-header-missing formatted the same []string the same way. Fixing only the reported flag would have left two assertions disagreeing with it. Closes #97 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CrknafJSP5hF8u865cbnqX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A failed header assertion printed Go's slice syntax at the user, and nothing anywhere said that a header can hold more than one value.
That bracket was also the only place the tool admitted the model is a list.
--assert-headerand--assert-header-eqhold when any value matches, so this passes against a response that sets three cookies:The flag said "Assert header equals the provided value" and the README said "exact value". Both read as a claim about the only value, and neither
--helpnor the README mentioned multi-valued headers at all.Solution
Render values the way a person writes them, and write the matching rule down in the three places a user would look.
Before / after, for the same two responses:
The semantics are unchanged — the ticket is right that any-value is the sensible default. What changes is that
--help, the flag descriptions and the README now say so, deliberately placed next to the existing paragraph about repeating the flag, which is a different thing and was the only nearby text a reader could mistake for this one.The reported flag was one of three
--assert-headerand--assert-header-missingformatted the same[]stringthe same way, so the bug had three manifestations, not one:--assert-header-eqexpected "nope", got ["a=1" "b=2"]--assert-headerexpected to match "^nope$", got ["a=1" "b=2"]--assert-header-missingexpected to be missing, got ["a=1" "b=2"]Fixing only the reported one would have left two assertions rendering disagreements with it.
Verification
New e2e tests cover the any-value rule for both matching flags, the strictness of
--assert-header-missing, both renderings, and a guard that no header failure containsgot [again. They were mutation-checked: withheaderValuesreverted to%qon the slice, five of the seven subtests fail.Manually reproduced the ticket's exact commands against a server with
X-Dup: first/X-Dup: secondand threeSet-Cookieheaders, before and after.Other Changes
--assert-header-missingregex that matchedgot \[.*\].Closes #97
🤖 Generated with Claude Code