Skip to content

Provide a configuration validation mechanism #10030

Open
@snicoll

Description

@snicoll
Member

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.

Activity

added this to the 2.x milestone on Feb 8, 2019
jkubrynski

jkubrynski commented on Feb 18, 2019

@jkubrynski
Contributor

Any progress with this issue? Being unable to easily debug such issues is really a pain in the neck

copitz

copitz commented on Oct 25, 2019

@copitz

As with #12601 ConfigurationProperties#ignoreInvalidFields will probably be deprecated, are there concrete plans to implement this?

philwebb

philwebb commented on Oct 25, 2019

@philwebb
Member

We don't have any immediate plans to look at this one. We have quite a few other strategically important issues that we need to look at before this one.

copitz

copitz commented on Oct 29, 2019

@copitz

Ok, thank you

Lacritz

Lacritz commented on Dec 5, 2019

@Lacritz

Any strategies to bypass the issue currently?

Having quiet some issues with not validating configuration properties before reloading the application entirely
Is there anything we can contribute for this particular issue?

Toerktumlare

Toerktumlare commented on Jan 28, 2022

@Toerktumlare

we are very interested in this feature, as we have configuration properties that are managed by non-developers that might use IDEs that dont display properly if configuration syntax is correct.

I was looking for an option to hard fail a service startup if there is an unknown property (all properties) and was suprised when i failed to find such feature.

modified the milestones: 2.x, 3.x on Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bclozel@snicoll@philwebb@jkubrynski@copitz

        Issue actions

          Provide a configuration validation mechanism · Issue #10030 · spring-projects/spring-boot