Ensure DefaultErrorAttributes adds JSON serialization safe errors#43330
Closed
YongGoose wants to merge 1 commit intospring-projects:mainfrom
Closed
Ensure DefaultErrorAttributes adds JSON serialization safe errors#43330YongGoose wants to merge 1 commit intospring-projects:mainfrom
YongGoose wants to merge 1 commit intospring-projects:mainfrom
Conversation
Signed-off-by: yongjunhong <kevin0928@naver.com>
Contributor
Author
|
If there are any issues with my approach or implementation, I would appreciate your feedback 😁 |
Member
|
@YongGoose I think from a cursory glance this is what we had in mind, but we won't be able to do a detailed review until we look at merging the PR. We can't do that until we branch for Spring Boot 3.5 which is still a few weeks away. |
Contributor
Author
|
@philwebb |
philwebb
pushed a commit
that referenced
this pull request
Jan 14, 2025
Update `DefaultErrorAttributes` implementations so that errors are wrapped for consistent JSON serialization. Prior to this commit, only `ObjectError` implementations were included in the 'errors' entry. Signed-off-by: yongjunhong <kevin0928@naver.com> See gh-43330
philwebb
added a commit
that referenced
this pull request
Jan 14, 2025
Polish code and extend wrapping to all error types. See gh-43330
Member
|
Thanks very much @YongGoose! |
wilkinsona
added a commit
that referenced
this pull request
Jul 7, 2025
In Spring Boot 3.5, support was added for including the errors from a MethodValidationResult in the standard error response. It was requested in gh-42013 and implemented in gh-43330. With hindsight, the implementation went too far as it changed how all errors are serialized to JSON. This commit reworks the wrapping so that ObjectErrors are not wrapped, restoring Spring Boot 3.4's behavior. This is considered safe as the contents of an ObjectError are fairly limited and should serialize to JSON without problems. Other MessageSourceResolvable implementations are still wrapped as there are no limits on their contents and we cannot predict how suitable they are for JSON serialization. Closes gh-46260
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.
resolved #42013
ErrorWrapperto enableDefaultErrorAttributesto handle errors related toMethodValidationResult.