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

Pick status code from ErrorResponse interfaces #942

Merged
merged 3 commits into from
Feb 2, 2024
Merged

Pick status code from ErrorResponse interfaces #942

merged 3 commits into from
Feb 2, 2024

Conversation

buttilda
Copy link
Contributor

@buttilda buttilda commented Jan 31, 2024

Unhandled exceptions that extend spring-boot's ErrorResponse have a status code defined and we should use that instead of forcing it to be 500

Description

Adding problem-spring-web to your project has a consequence of turning exceptions which haven't been explicitly handled into 500s. While at face value this may seem like a reasonable default behaviour, one should take into consideration that spring-boot can throw errors internally which have status codes attached to them, so it's only fair that problem should listen to those and pass them forwards.

Motivation and Context

Adding problem-spring-web to a bare spring-boot project and extending from ProblemHandling causes errors to turn into 500s. For example, calling an endpoint that doesn't exist results in 500 Resource not found instead of 404 Resource not found which is the default and expected behaviour.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

unhandled exceptions that extend spring-boot's `ErrorResponse` have a status code defined and we should use that instead of forcing it to be `500`
@buttilda buttilda marked this pull request as ready for review January 31, 2024 13:21
@buttilda buttilda requested a review from a team as a code owner January 31, 2024 13:21
@MALPI
Copy link
Member

MALPI commented Feb 2, 2024

👍

@MALPI MALPI merged commit 507bab9 into zalando:main Feb 2, 2024
2 checks passed
@buttilda buttilda deleted the patch-2 branch February 2, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants