Skip to content

fix: match vendor media type case-insensitively#18

Merged
lesnik512 merged 1 commit into
mainfrom
fix/vendor-media-type-case-insensitive
Jul 4, 2026
Merged

fix: match vendor media type case-insensitively#18
lesnik512 merged 1 commit into
mainfrom
fix/vendor-media-type-case-insensitive

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Problem

parse_accept_version compared the request media type (already lowercased by get_accept_header_from_scope) against vendor_media_type exactly as configured. A mixed-case configured vendor — e.g. application/vnd.Some.Name+json — never matched, so requests silently fell through to Ignore and defaulted to v1.0.

Media types are case-insensitive: RFC 9110 §8.3.1 (type/subtype/parameter-name tokens case-insensitive) and RFC 6838 §4.2 ("Both top-level type and subtype names are case-insensitive").

Fix

Lowercase the vendor in the comparison only:

if media_type.strip() != vendor_media_type.lower():
    return Ignore()

Robustness principle: liberal in what we accept (case-insensitive match), conservative in what we send — the response content-type still echoes the exact casing the user configured (that string is untouched). Normalizing at init instead was rejected because it would also rewrite the emitted content-type casing, a change beyond the bug with no spec basis.

Tests

TDD: tests/test_accept.py::test_parse_matches_vendor_case_insensitively — a mixed-case vendor matches a lowercased request media type → ParsedVersion. Failed with Ignore() == ParsedVersion(version=(1, 0)) before the fix; passes after.

  • just test-ci — 32 passed, coverage 100%.
  • just lint-ci — ruff + ty clean, planning: OK.

Clears the deferred item recorded in PR #17. Planning bundle: planning/changes/2026-07-04.02-vendor-media-type-case-insensitive/.

🤖 Generated with Claude Code

The request media type is lowercased on the way in, but the configured
vendor was compared as-is, so a mixed-case vendor (e.g.
application/vnd.Some.Name+json) never matched and requests silently fell
through to Ignore / the v1.0 default. Media types are case-insensitive
(RFC 9110 8.3.1, RFC 6838 4.2), so lowercase the vendor in the comparison.
The response content-type still echoes the configured casing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 7de1c03 into main Jul 4, 2026
6 checks passed
@lesnik512 lesnik512 deleted the fix/vendor-media-type-case-insensitive branch July 4, 2026 11:32
lesnik512 added a commit that referenced this pull request Jul 4, 2026
…#22)

* docs(planning): add 1.4.7 release notes

Case-insensitive vendor matching fix (#18) plus internal refactors (#17, #21) since 1.4.6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(planning): record vendor-media-type process-global decision

Review #2 candidate B: keep VENDOR_MEDIA_TYPE as class-global state; instance-scoping collides with the response-class mechanism and one-vendor-per-process is accepted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(architecture): seed capability pages and glossary

Living-truth pages for Accept-header version negotiation and OpenAPI schema versioning, plus the ubiquitous-language glossary.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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