Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebFlux returns 406 instead of RFC 7807 response for subtype of ProblemDetail #30533

Closed
vijjayy81 opened this issue May 24, 2023 · 1 comment
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@vijjayy81
Copy link

The following line causing 406 Error while using any subtype of ProblemDetail class.

		// For ProblemDetail, fall back on RFC 7807 format
		if (bestMediaType == null && elementType.toClass().equals(ProblemDetail.class)) {
			bestMediaType = selectMediaType(exchange, () -> getMediaTypesFor(elementType), this.problemMediaTypes);
		}

(https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java#L178)

The issue does not exists in Servlet as it checks the error body type is assignable of ProblemDetail class.

			// For ProblemDetail, fall back on RFC 7807 format
			if (compatibleMediaTypes.isEmpty() && ProblemDetail.class.isAssignableFrom(valueType)) {
				determineCompatibleMediaTypes(this.problemMediaTypes, producibleTypes, compatibleMediaTypes);
			}

https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java#L247

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 24, 2023
@rstoyanchev rstoyanchev self-assigned this May 30, 2023
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 30, 2023
@rstoyanchev rstoyanchev added this to the 6.0.10 milestone May 30, 2023
@rstoyanchev rstoyanchev changed the title Webflux - Exception Handler - ProblemDetail subtype usage causing 406 error WebFlux returns 406 instead of an RFC 7807 for subtype of ProblemDetail WebFlux May 30, 2023
@rstoyanchev rstoyanchev changed the title WebFlux returns 406 instead of an RFC 7807 for subtype of ProblemDetail WebFlux WebFlux returns 406 instead of RFC 7807 response for subtype of ProblemDetail May 30, 2023
@rstoyanchev
Copy link
Contributor

Thanks for the report and analysis.

mdeinum pushed a commit to mdeinum/spring-framework that referenced this issue Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants