Skip to content

Conversation

@YongGoose
Copy link
Contributor

resolved #42013

  • Added ErrorWrapper to enable DefaultErrorAttributes to handle errors related to MethodValidationResult.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 29, 2024
@YongGoose
Copy link
Contributor Author

@wilkinsona @philwebb

If there are any issues with my approach or implementation, I would appreciate your feedback 😁

@philwebb
Copy link
Member

philwebb commented Dec 3, 2024

@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.

@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 3, 2024
@philwebb philwebb added this to the 3.5.x milestone Dec 3, 2024
@YongGoose
Copy link
Contributor Author

@philwebb
Thank you for the detailed explanation!
I'll wait for the branching process for Spring Boot 3.5 and the subsequent review.

@philwebb philwebb self-assigned this Jan 13, 2025
@philwebb philwebb changed the title Add ErrorWrapper to populate errors for MethodValidationResult Ensure DefaultErrorAttributes adds JSON serialization safe errors Jan 14, 2025
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 <[email protected]>

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
@philwebb philwebb closed this in e2a62d6 Jan 14, 2025
@philwebb philwebb modified the milestones: 3.5.x, 3.5.0-M1 Jan 14, 2025
@philwebb
Copy link
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultErrorAttributes doesn't populate errors for MethodValidationResult

3 participants