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

Handle case where ResponseEntity and ProblemDetail don't agree on the HTTP status to use #29378

Closed
rstoyanchev opened this issue Oct 25, 2022 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

ResponseEntity has a dedicated method ResponseEntity.of(ProblemDetail), which uses the status property of ProblemDetail and returns a builder to add headers, or one can also return just ProblemDetail, if there is no need to add headers. However, if ResponseEntity wraps a ProblemDetail as any other body, i.e. not using the dedicated method, and the status from the ResponseEntity which actually sets the response, could be mismatched with the one listed in the body.

One option would be to reject this, but than a 500 error would obscure the original problem, and would only be discovered at runtim. In that sense, it might be better for the client to get a response with the status from the ResponseEntity, even if the body details, which should be informational, don't agree.

Perhaps the best middle ground would be to log a warning to ensure this is noticed proactively, while the client still has a better chance of handling the response than they would with a 500.

@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Oct 25, 2022
@rstoyanchev rstoyanchev added this to the 6.0.0-RC3 milestone Oct 25, 2022
@rstoyanchev rstoyanchev self-assigned this Oct 25, 2022
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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant