Fix #305: Sanitize error details and add validation tests for owner pets#306
Open
San-43 wants to merge 6 commits intospring-petclinic:masterfrom
Open
Fix #305: Sanitize error details and add validation tests for owner pets#306San-43 wants to merge 6 commits intospring-petclinic:masterfrom
San-43 wants to merge 6 commits intospring-petclinic:masterfrom
Conversation
Contributor
Author
|
Hey @vfedoriv srry to bother you, any thoughts on this? |
Collaborator
|
@San-43 looks fine, except one detail - as I see, not a |
94f4a67 to
306a2e3
Compare
Contributor
Author
|
Hello @vfedoriv, I think this is correct now. I have one question though: since |
306a2e3 to
407c039
Compare
26e0c99 to
9d3c02b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #305.
I updated the global exception handling, so API errors are more consistent and don’t expose internal technical details.
What changed
ExceptionControllerAdvicehas been updated. It now provides generic, safe messages when unexpected errors occur, when requests are invalid, or when data integrity issues are detected.ProblemDetailnow always includesschemaValidationErrors(empty by default).MethodArgumentNotValidException),schemaValidationErrorsis populated fromBindingResult.Why this change
OpenAPI currently defines
schemaValidationErrorsinProblemDetail, so this PR aligns runtime behavior with that contract while keeping messages client-safe and non-technical.Tests
OwnerRestControllerTeststo match the new error format.schemaValidationErrorsis present for validation errorsFeedback is welcome if you think something should be adjusted or improved.