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

Fix RFC-7807 content negotiation #29918

Closed
wants to merge 3 commits into from
Closed

Fix RFC-7807 content negotiation #29918

wants to merge 3 commits into from

Conversation

ueberfuhr
Copy link

This PR fixes #29588, where we discussed the intended behavior concerning content negotiation with RFC-7807 content types.
This is a solution that

  • prefers RFC-7807 content types in case of returning a ProblemDetail (error response)
  • excludes RFC-7807 content types in case of returning all other types (success response)

The test simply allows to add further test cases. Currently, there's no support for ProblemDetail serialized with JAXB (application/problem+xml), but if it is added in the future, the test adds test cases automatically.

- prefer RFC-7807 content-types in case of returning a ProblemDetail (error response)
- exclude RFC-7807 content-types in case of returning all other types (success response)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 2, 2023
@ueberfuhr
Copy link
Author

Those are the test cases (=requirements):

image

@ueberfuhr ueberfuhr marked this pull request as draft February 2, 2023 11:38
@ueberfuhr ueberfuhr marked this pull request as ready for review February 2, 2023 12:12
@ueberfuhr ueberfuhr marked this pull request as draft February 2, 2023 12:53
@ralf-ueberfuhr-ars
Copy link

I found another issue while fixing the tests: There's one test case throwing an exception and expecting the MVC layer to create a response with an application/problem+json content type and a JSON object, that does not match the requirements of this content type, because it does not conform RFC 7807. (see org.springframework.web.servlet.mvc.method.annotation.ServletAnnotationControllerHandlerMethodTests#produces(boolean))

Is it reasonable to wrap the currently returned body into an RFC-7807-compliant ProblemDetails object instead?

@ueberfuhr ueberfuhr marked this pull request as ready for review February 2, 2023 14:14
@rstoyanchev rstoyanchev self-assigned this Feb 2, 2023
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Feb 2, 2023
@rstoyanchev
Copy link
Contributor

There is now a fix for #29588, so I'm going to close this. Thanks for the PR in any case.

@rstoyanchev rstoyanchev closed this Feb 7, 2023
@rstoyanchev rstoyanchev added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 7, 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) status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefer problem detail media type independent of ordering in Accept header
4 participants