Skip to content

Match path before Content-Type in GraphQlRequestPredicates - #1531

Closed
kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:gh-1485-path-before-content-type
Closed

kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:gh-1485-path-before-content-type

Conversation

@kalayciburak

Copy link
Copy Markdown

Fixes #1485

GraphQlRequestPredicates evaluated Content-Type (and Accept) before the request path. Since #1145, contentTypeMatch throws UnsupportedMediaTypeStatusException for an unparseable Content-Type. RouterFunctionMapping runs that predicate during handler lookup for every request, so any POST in the application with a malformed header was answered 415 even when it did not target the GraphQL endpoint.

This change evaluates pathMatch first in both the WebMVC and WebFlux predicates. Requests to other paths are unaffected. The deliberate 415 from #1145 is unchanged for requests aimed at the GraphQL path (shouldRejectRequestWithInvalidContentType still expects UnsupportedMediaTypeStatusException).

Test plan

Executed:

  • RED then GREEN ./gradlew :spring-graphql:test --tests org.springframework.graphql.server.webmvc.GraphQlRequestPredicatesTests --tests org.springframework.graphql.server.webflux.GraphQlRequestPredicatesTests → 56/0

GraphQlRequestPredicates evaluated Content-Type before the request
path. Since spring-projects#1145, an unparseable Content-Type throws 415 during
handler lookup, so any POST in the application with a malformed
header was rejected even when it did not target the GraphQL
endpoint.

Evaluate the path first so only GraphQL routes apply that check.
The 415 for invalid Content-Type on the GraphQL path is unchanged.

Fixes spring-projects#1485

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 19, 2026
@bclozel

bclozel commented Sep 21, 2026

Copy link
Copy Markdown
Member

Thanks for the proposal but I went in a different direction.

@bclozel bclozel closed this Sep 21, 2026
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQlRequestPredicates rejects requests to non-GraphQL paths with 415 when the Content-Type is unparseable (path is matched last)

3 participants