spring-projects / spring-projects/spring-boot

Provide a configuration validation mechanism

Open
#10,030 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

theme: config-data type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing --debug behavior, @ConfigurationProperties#ignoreInvalidFields, the /application/configprops endpoint, and the FailureAnalyzer concept. Review the relationship to issue #9936 and determine the validation scope, false-positive handling, failure collection, and readable error report needed for a complete design.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.