Skip to content

fix(metadata): negotiate wildcard Accept with parameters#8192

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/1532-wildcard-accept
May 22, 2026
Merged

fix(metadata): negotiate wildcard Accept with parameters#8192
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/1532-wildcard-accept

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented May 21, 2026

Summary

  • willdurand/negotiation treats media-range parameters as match constraints, so */*; charset=utf-8 (sent by default by clients like PhpStorm) fails to match offered MIME types and returns 406 Not Acceptable.
  • On failure, retry with a bare */* when the Accept header contains a wildcard. Concrete media types are left untouched so vendor-specific negotiation (e.g. JSON:API profile) is preserved.

Test plan

  • */* picks first configured format
  • */*; charset=utf-8 picks first configured format (the Content-Type */* generates error when format restriction configured #1532 fix)
  • */*; charset=utf-8; q=0.1, text/html; q=0.9 still picks text/html (q-precedence preserved)
  • Unsupported concrete type (e.g. application/xml) still returns 406
  • Existing FormatTest, ErrorFormatTest, JsonLdTest, JsonApiTest, ContentNegotiationProviderTest all green

Closes #1532

willdurand/negotiation treats media-range parameters as match
constraints, so `*/*; charset=utf-8` (sent by default by some
clients like PhpStorm) fails to match offered MIME types that do
not carry the same parameter, returning 406 Not Acceptable.

Retry with a bare `*/*` on failure when the Accept header contains
a wildcard. Concrete media types are left untouched so vendor-
specific negotiation (e.g. JSON:API `profile`) is preserved.

Closes api-platform#1532
@soyuka soyuka merged commit 84d15b1 into api-platform:4.3 May 22, 2026
120 checks passed
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