Skip to content

Provide a configuration validation mechanism #10030

Open
@snicoll

Description

@snicoll

It would be nice if Spring Boot had a specific flag that would turn on extensive configuration validation, something similar to what we have with --debug (--config-validation?).

Let's say the user made a typo in a property or edited a file used by the config server with no assistance. If you know what you are looking for and the application starts and you have the actuator you can hit /application/configprops to see if the property has been bound properly. This works but we could do better.

The binding has already an option to fail if we are not able to bind a particular property (see @ConfigurationProperties#ignoreInvalidFields). One idea would be to have a mode where:

  • This flag is turned on for everything
  • For every failed attempt at binding a property we would keep a reference to the failure (rather than throwing an exception as this flag currently does)
  • If there are some unbounded properties, throw an exception coupled with a FailureAnalyzer that provides a nice and readable report (We do have some concept of origin of the property in 2.0 so we should use that)

I am pretty convinced that turning on this mechanism on a perfectly valid application will generate false positive but we may find a way to mitigate that.

This issue related to #9936 and, IMO, should supersede it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions