-
Notifications
You must be signed in to change notification settings - Fork 38.1k
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
Prefer problem detail media type independent of ordering in Accept header #29588
Comments
I wouldn't call it broken. We're returning JSON after, but we can refine the behavior. |
There're multiple problems with the current behavior:
|
@ralf-ueberfuhr-ars, thanks for your time and feedback, and for the attached draft PR. Note that I have local changes in progress too, but before implementation details, we should discuss desired behavior. For the Adidas API guidelines, I presume you're referring to:
This is not something we consider explicitly because there should never be a 2xx response with |
@osiegmar, thinking further about:
We compare Accept header media types to supported media types (i.e. those supported by each For I think you are proposing to always use It means we would mostly ignore the Accept header for |
Thanks for all your feedback and analysis @ralf-ueberfuhr-ars and @rstoyanchev! After thinking about it for a while now and re-reading RFC 7807 my conclusion would be:
Did I miss something? What do you think? |
I agree, and I would add:
Further points:
An example for the last bullet:
(Excuse my complicated way of thinking. 😅) |
Good catch! I just tried it and received an invalid Problem Details XML document: curl -H "Accept: application/problem+xml" -i http://localhost:8080/rest/foo <ProblemDetail><type>about:blank</type><title>Not Found</title><status>404</status><detail>No endpoint GET /rest/foo.</detail><instance>/rest/foo</instance></ProblemDetail> The root node has to be Need to think about the other points 😴 😄 |
The question is, what sense does it make for a client to specify an Accept Header of only a problem type? Nobody requests the server especially to expect a problem. 😉 And what would then be the format of the 2xx response? (I guess JSON for objects, and plain text for strings, right?) As already said, specifying a problem type in the Accept header would only make sense, if the client tells the server, which format of problem responses it is able to deal with, or which it prefers. |
No, I meant
Because this would break with the initial problem reported by @osiegmar. |
This is getting quite complex. I think we should separate issues.
|
Thanks again for the thoughts and feedback. I've made a change to the Jackson message converter to return
The Jackson message converter returns If you could please give it a try. The changes are now in the latest 6.0.5-SNAPSHOT. |
I will respond separately under #29927 for For selecting JSON or XML problem details, I don't think the presence of For example, I can imagine a client that calls a REST API using different content types depending on the specific endpoints, but otherwise expecting to handle error responses as For the time being we will not treat |
Thanks for your feedback and fix @rstoyanchev! I gave 6.0.5-SNAPSHOT a try and now almost all my tests are green. Now waiting for related spring-projects/spring-boot#33716 to be fixed to solve the others. ;-) |
Thanks for confirming, much appreciated. |
While replacing a custom implementation of Problem Details by the new one that came with Spring 6 I was puzzled by how content negotiation is implemented. I'm currently using Spring Boot 3.0.0 with Spring 6.0.2.
I'm getting a Content-Type
application/problem+json
as expected when sending no accept header orAccept: */*
orAccept: application/problem+json, application/json
.I also expected to receive a Problem Details JSON with Content-Type
application/problem+json
when sendingAccept: application/json
. But that might be correct - it doesn't seem to be clearly defined by RFC 7807.Clearly a bug, seems that I'm still getting Content-Type
application/json
when sendingAccept: application/json, application/problem+json
. See also:from: #28189 (comment)
The text was updated successfully, but these errors were encountered: