vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
879 stars 57 forks source link

Bean-Validation-Errors inproperly reported to frontend and no way to customize #1960

Open cproinger opened 6 months ago

cproinger commented 6 months ago

Describe the bug

curretnly dev.hilla.EndpointInvoker#createBeanValidationErrors just formats the whole information from ConstraintViolations as a String and there is no way to customize this behavior.

this problem is present in versiion 1.3 and as far as i can see the situation did not change in the main-branch https://github.com/vaadin/hilla/blob/main/packages/java/endpoint/src/main/java/com/vaadin/hilla/EndpointInvoker.java#L241

resulting in strings formatted with the template "Object of type '%s' has invalid property '%s' with value '%s', validation error: '%s'" which cannot be shown to the user

Expected-behavior

if you cannot implement a better way to propagate constraint-violation-data please at least extract this method into a bean where framework-users can provide their own implemetation via spring-bean to customize this

Reproduction

use a request-parameter with some bean-validation-constraints on it (besides what hilla handles on the frontend)

System Info

version 1.3.19, but the problem is present on the main branch currently as well

krissvaa commented 6 months ago

With https://github.com/vaadin/hilla/pull/1939 there will be validatorMessage in ValidationErrorData available for this reason.