Skip to content

DefaultErrorWebExceptionHandler should ignore invalid Accept header #13372

@rstoyanchev

Description

@rstoyanchev

Originally reported in SPR-16903 but the root cause is in DefaultErrorWebExceptionHandler.

The scenario is a bogus accept header, e.g. "Accept: v=3.0" which results in NotAcceptableStatusException initially (406) but then becomes InvalidMediaTypeException (500) during error handling.

org.springframework.http.InvalidMediaTypeException: Invalid mime type "v=3.0": does not contain '/'org.springframework.http.InvalidMediaTypeException: Invalid mime type "v=3.0": does not contain '/'
at org.springframework.http.MediaType.parseMediaType(MediaType.java:534)
at org.springframework.http.MediaType.parseMediaTypes(MediaType.java:558)
at org.springframework.http.MediaType.parseMediaTypes(MediaType.java:577)
at org.springframework.http.HttpHeaders.getAccept(HttpHeaders.java:443)
at org.springframework.web.reactive.function.server.DefaultServerRequest$DefaultHeaders.accept(DefaultServerRequest.java:220)
at org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler.lambda$acceptsTextHtml$3(DefaultErrorWebExceptionHandler.java:190)
at org.springframework.web.reactive.function.server.RouterFunctions$DefaultRouterFunction.route(RouterFunctions.java:396)
at org.springframework.web.reactive.function.server.RouterFunctions$SameComposedRouterFunction.route(RouterFunctions.java:317)
at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.handle(AbstractErrorWebExceptionHandler.java:239)
at org.springframework.web.server.handler.ExceptionHandlingWebHandler.lambda$handle$0(ExceptionHandlingWebHandler.java:68)
...

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions