Skip to content

Fix: q weight on Accept/Content-Type wrongly treated as a media type parameter - #129

Merged
thomasfosterau merged 1 commit into
mainfrom
claude/clever-brown-ydlhgc
Sep 13, 2026
Merged

thomasfosterau merged 1 commit into
mainfrom
claude/clever-brown-ydlhgc

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

RFC 9110 §12.4.2: q terminates a media type's parameter list — it and
everything after it are accept-extension parameters belonging to the
header field, not the media type. JSON:API §5's ext/profile whitelist
governs only the media type's own parameters, so q must not count
against it.

parseMediaType now splits positionally: parameters before q are checked
against the ext/profile whitelist as before; q itself and any parameter
after it are stripped and never checked. acceptIsAcceptable also treats
a q=0 entry as an explicit refusal rather than a malformed parameter,
so it's skipped rather than rejected for the wrong reason.

Fixes #101. Two existing tests (src/Atomic.test.ts,
examples/blog/test/blog.test.ts) asserted the old buggy behavior for
q and are updated to match the corrected semantics.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01YRZS52nrSowy8EphoU5rbJ

…parameter

RFC 9110 §12.4.2: q terminates a media type's parameter list — it and
everything after it are accept-extension parameters belonging to the
header field, not the media type. JSON:API §5's ext/profile whitelist
governs only the media type's own parameters, so q must not count
against it.

parseMediaType now splits positionally: parameters before q are checked
against the ext/profile whitelist as before; q itself and any parameter
after it are stripped and never checked. acceptIsAcceptable also treats
a q=0 entry as an explicit refusal rather than a malformed parameter,
so it's skipped rather than rejected for the wrong reason.

Fixes #101. Two existing tests (src/Atomic.test.ts,
examples/blog/test/blog.test.ts) asserted the old buggy behavior for
q and are updated to match the corrected semantics.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YRZS52nrSowy8EphoU5rbJ
@thomasfosterau
thomasfosterau merged commit ce663f3 into main Sep 13, 2026
2 checks passed
@thomasfosterau
thomasfosterau deleted the claude/clever-brown-ydlhgc branch September 15, 2026 07:11
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.

Content negotiation treats an Accept q-weight as a media type parameter, so Accept: application/vnd.api+json;q=0.9 gets a spurious 406

2 participants