Description
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
jkubrynski commentedon Feb 18, 2019
Any progress with this issue? Being unable to easily debug such issues is really a pain in the neck
copitz commentedon Oct 25, 2019
As with #12601
ConfigurationProperties#ignoreInvalidFields
will probably be deprecated, are there concrete plans to implement this?philwebb commentedon Oct 25, 2019
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 commentedon Oct 29, 2019
Ok, thank you
Lacritz commentedon Dec 5, 2019
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 commentedon Jan 28, 2022
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.