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

Change of behaviour for UUID in bean validation output in v5.3.27 #30661

Closed
vandeven opened this issue Jun 13, 2023 · 5 comments
Closed

Change of behaviour for UUID in bean validation output in v5.3.27 #30661

vandeven opened this issue Jun 13, 2023 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Milestone

Comments

@vandeven
Copy link

vandeven commented Jun 13, 2023

Affects: 5.3.27


Hello spring team!
I tried to update my spring-boot application, and I found a change of behaviour in bean validation output on how it renders UUID's
The old behaviour would show the .toString() version of the UUID, the new version would show the object id instead.
I traced it down to this change:

https://github.com/spring-projects/spring-framework/blob/v5.3.26/spring-context/src/main/java/org/springframework/validation/FieldError.java
to
https://github.com/spring-projects/spring-framework/blob/v5.3.27/spring-context/src/main/java/org/springframework/validation/FieldError.java

in the toString() of FieldError ObjectUtils.nullSafeToString(this.rejectedValue) was changed to ObjectUtils.nullSafeConciseToString(this.rejectedValue)

Here it checks if it is a "isSimpleValueType" and if so, it calls the toString() and otherwise it returns the typename.
From reading the issues I think this change happend because otherwhise whole object hierarchies would be included, which is not really useful. UUID's do sound like an exception to this rule.
I do not mind making a pull request for this myself (would be nice to help spring :)) but I would like some guidance to where you think it is best to solve this (if you consider this desirable behaviour). I could UUID to the isSimpleValueType method, or should I make a special case for this?

Kind regards

Ties

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 13, 2023
@jhoeller jhoeller changed the title Change of behaviour in bean validation output in v5.3.27 Change of behaviour for UUID in bean validation output in v5.3.27 Jun 13, 2023
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 13, 2023
@jhoeller jhoeller self-assigned this Jun 13, 2023
@jhoeller jhoeller added this to the 6.0.10 milestone Jun 13, 2023
@jhoeller
Copy link
Contributor

This is a regression caused by #30286. Since we intend to release 6.0.10 and 5.3.28 this week, I'll pick this up directly.

Thanks for the report, and thanks for volunteering! With more lead-up time, I'd be happy to help with a pull request next time.

@jhoeller jhoeller added the for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x label Jun 13, 2023
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x labels Jun 13, 2023
@vandeven
Copy link
Author

Ok :) thank you!

@jhoeller
Copy link
Contributor

jhoeller commented Jul 3, 2023

@vandeven since we're considering a wider revision here for 6.0.11 / 5.3.29, could you please clarify how you are consuming the FieldError.toString() output for which the UUID rendering mattered above? Are you calling the method directly (like in #30799) or indirectly via Errors/BindingResult/BindException?

@vandeven
Copy link
Author

vandeven commented Jul 3, 2023

I was doing it indirectly through bean validation. @Valid in combination with a custom ConstraintValidator, resulting in an error message: org.springframework.validation.BeanPropertyBindingResult: 3 errors
Field error in object 'MyObject' on field 'myField': rejected value [java.util.UUID@384f0e32]

(omitted some parts because it is code of the client im working for)

and we get this result from just calling mockmvc

mockMvc.perform(post("/myurl").andReturn().getResolvedException();

And I cannot seem to find any error handler for this.

@sbrannen
Copy link
Member

sbrannen commented Jul 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants