Skip to content

Rejected value is null when configuration property fails validation #19580

@tazle

Description

@tazle

After changing from Spring Boot 2.1.9 to Spring Boot 2.2.2, the error messages about constraint validation for some of our configuration properties started including null as the rejected value, rather than the actual value (-1 in this case).

The root cause seems to be that SpringValidationAdapter's getRejectedValue(ield, violation, bindingResult) has started returning null in certain cases with the bindingResult that's present in 2.2.2. Or rather, the getRawFieldValue(String) has started returning null.

Failing case in 2.2.2:
SpringValidationAdapter calls ValidationBindHandlers$ValidationResult.getRawFieldValue("intermediatefield.leafFieldInCamelCase")which returns null because it expects field names in form "intermediatefield.leaf-field-in-camel-case".

Working case in 2.1.9:
SpringValidationAdapter calls BeanPropertyBindingResult.getRawFieldValue("intermediatefield.leafFieldInCamelCase") which returns the actual field value.

I'll try to produce a minimal reproduction later.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions