Skip to content

[backport into 4.x] correct property values from enums are sometimes flagged as error #1606

@martinlippert

Description

@martinlippert

Backport issue for #1605 for the 4.32.0 release:

management.endpoint.health.show-details=when_authorized

is flagged as an error, even though the Spring Boot internally converts when_authorized correctly to Show.WHEN_AUTHORIZED.

It looks like the validation logic around enum values for properties is currently:

  • lower-case name of the enum with - instead of _ (when-authorized does not show an error)
  • upper-case exact name of the enum (WHEN_AUTHORIZED does not show an error)

But the conversion logic in Spring Boot is a little different. It is located in LenientObjectToEnumConverterFactory. It basically is:

  • does the value match the exact enum value (in this case WHEN_AUTHORIZED)
  • if not, then strip all non-digit and non-letter characters, convert to lowercase, and find the enum value that way.

That results in:

  • when_authorized is mapped to WHEN_AUTHORIZED
  • when-authorized is mapped to WHEN_AUTHORIZED
  • WHEN-AUTHORIZED is mapped to WHEN_AUTHORIZED

This should be reflected in the validation logic for the property editors (.properties + .yml).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions