Skip to content

ValidationHandler no longer works with certain map keys #20350

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

Closed
zzcoder opened this issue Feb 28, 2020 · 2 comments
Closed

ValidationHandler no longer works with certain map keys #20350

zzcoder opened this issue Feb 28, 2020 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@zzcoder
Copy link

zzcoder commented Feb 28, 2020

Just upgraded Spring Boot from 2.1.4.RELEASE to 2.2.5.RELEASE and my application.yml doesn't validate any longer.

For example, in this yaml, the itemOne works in previous version but fails validation now.

test:
  items:
    itemOne:
      COLOR: RED
    ITEM2:
      COLOR: BLUE

It seems any nested map key with uppercase letters will fail. Tried to debug and found getName() in
ValidationBindHandler mangles the key into

test.items[item-one].color
test.items[-i-t-e-m2].color

This is apparently incorrect.

The code to reproduce the error is at https://github.com/zzcoder/spring-validation-bug

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 28, 2020
@OrPolyzos
Copy link

Apparently this is caused by the fix for the #19580

@mbhave
Copy link
Contributor

mbhave commented Mar 3, 2020

This appears to be caused by #17424. Instead of getting the value of the field using the getter it uses the boundResults to look up the value. The field name doesn't match any names in the boundResults lists and the value is null, failing the rejectIfEmptyOrWhitespace validation.
In the same above, the fieldName is test.items[item-one].color whereas boundResults contains the key test.items.itemone.color.

@mbhave mbhave added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 3, 2020
@mbhave mbhave added this to the 2.2.x milestone Mar 3, 2020
@mbhave mbhave self-assigned this Apr 21, 2020
@philwebb philwebb self-assigned this Sep 13, 2020
@philwebb philwebb modified the milestones: 2.2.x, 2.2.10 Sep 13, 2020
@philwebb philwebb changed the title Validation Error for Nested Map Keys with Uppercase ValidationHandler no longer works with certain map keys Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants