Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

How would you standardise configuration validation across all services so that misconfiguration is found before deploy?

I would make every service keep its typed configuration in @ConfigurationProperties classes with @Validated, so bad values fail fast at startup rather than at first use, and then move that same check before deploy: a CI step starts the application context with each environment's configuration, without external connections where possible. On top of that, configuration diffs per environment are reviewed as part of each release, and the configuration metadata is used to detect unknown or deprecated properties, which validation alone cannot see.

Why this question is asked

Misconfiguration found in production is expensive: a pod that crashes during rollout is the good case, and a service that starts and then fails on its first real request is the bad case. The aim of a fleet-wide standard is to find both kinds of mistakes before anything is deployed, in the pull request that introduced them. Interviewers ask this design question because it combines Spring Boot knowledge, CI design and release process, and because the obvious answer, add validation annotations, covers only part of the problem. In this answer, we will go through the layers of the standard: validation in the code, failing fast at startup, a CI context start per environment, detection of unknown and deprecated keys from metadata, and review of configuration diffs, and then see how to roll it out.

1Layer 1: Typed and Validated Configuration in Every Service

The base layer is in the code. All typed configuration lives in @ConfigurationProperties classes annotated with @Validated, with Bean Validation constraints that express what we know: required values with @NotNull or @NotBlank, ranges with @Min and @Max, formats with @Pattern or @URL, and @Valid on nested groups. The rules then live next to the fields, are tested like code, and produce a standard failure message that names the property, the value and its origin.

This is also what makes the later layers possible. A CI check can only validate what the code declares, and a metadata check can only know the valid keys if the classes exist.

Java
@Validated
@ConfigurationProperties("orders.db")
public record OrdersDbProperties(
@NotBlank String url,
@DefaultValue("10") @Min(1) @Max(100) int poolSize,
@DefaultValue("2s") Duration connectTimeout) {}

2Layer 2: Fail Fast at Startup, Not at First Use

Failing fast means the service refuses to start when configuration is wrong. @Validated classes do this for the values they bind, but some problems only appear when a bean is used: a client that is created lazily, a URL that is only read on the first request, a value read with @Value in a code path that runs once a day. The standard should therefore forbid lazy initialisation for configuration-dependent beans and prefer constructor injection of properties classes, so binding and validation happen during startup.

In Kubernetes, failing at startup has a direct benefit: the new pod never becomes ready, the rollout stops at the first pod, and the old version keeps serving traffic. Failing at first use means every new pod becomes ready, the old version is gone, and the failure reaches users.

3Layer 3: Start the Context per Environment in CI

The step that moves detection before deploy is a CI job that starts the application context with each environment's real configuration files, the same values the deployment will supply, but without connecting to databases, brokers or other services where possible. Binding and validation happen during context creation, so a bad production value fails this job, in the pull request that introduced it.

Java
@ParameterizedTest
@ValueSource(strings = {"qa", "stage", "prod-eu", "prod-us"})
void configurationBindsAndValidates(String env) {
new ApplicationContextRunner()
.withUserConfiguration(PropertiesOnlyConfig.class) // only @ConfigurationPropertiesScan
.withInitializer(new ConfigDataApplicationContextInitializer())
.withPropertyValues("spring.config.location=classpath:/application.yml,file:deploy/" + env + "/values.yml")
.run(ctx -> assertThat(ctx).hasNotFailed());
}
// prod-eu: orders.db.pool-size: 500
// -> Property: orders.db.pool-size Value: "500" Reason: must be less than or equal to 100
Step throughWhere each layer catches a mistake
  1. Developer changes prod valuespull request opened
  2. Metadata check: is every key known?typo or deprecated key
    YesContinueNoFail: unknown key payments.time-out
  3. CI context start per environmentbinding and @Validated rules
    YesContinueNoFail: value out of range
  4. Reviewer reads the per-environment diffintent and risk
  5. Deploy; startup validates againlast line of defence

5 steps in order. Play them, or step through them one at a time.

Notice the trade-off in how much of the context we start. Starting only the properties classes is fast and needs no external systems, and it catches every binding and validation error. Starting the full application with test containers catches more, such as a bean that fails because of a wrong combination of values, but costs minutes. Many teams run the light check on every pull request and the full one nightly. The exact way to load deployment values in the test depends on how the platform delivers them, so the platform team should provide this test as a shared template.

4Layer 4: Detect Unknown and Deprecated Properties

Validation has a blind spot: a misspelt key. If the values file says orders.db.pool-sise: 50, nothing binds to it, nothing fails, and the service runs with the default pool of 10. Bean Validation cannot see a property that no field asked for.

The configuration metadata closes that gap. The spring-boot-configuration-processor writes a list of every known property, from our own classes and from Spring Boot and its libraries, into each jar. A CI step compares every key in the environment's values files and ConfigMaps against that list and fails on unknown keys, or warns on keys marked deprecated in the metadata. For environment variables, the check first maps names such as ORDERS_DB_POOLSISE back to their canonical form. During upgrades, Spring Boot's spring-boot-properties-migrator module can also report renamed properties at startup.

5Layer 5: Review Configuration Diffs per Environment

Automation catches errors; reviewers catch intent. For each release, the pipeline shows the effective configuration change per environment, what is different in prod-eu compared with the last release, in the pull request or the release notes. A reviewer then sees that a timeout went from 3s to 300s and can ask whether that was meant. Values that differ sharply between environments, such as a pool five times larger in one region, are worth highlighting automatically.

What each layer catches
LayerCatchesMisses
@Validated classesmissing, malformed, out-of-range valuesmisspelt keys
Fail fast at startuperrors in eagerly created beansnothing before deploy
CI context start per envall binding errors, before deployerrors needing real systems
Metadata key checktypos, deprecated keyswrong but valid values
Diff reviewunintended but valid changesanything a reviewer skims
No single layer is enough; together they cover each other's gaps.

6Rolling It Out Across Services

To make the standard real, the platform provides it rather than asking each team to build it. The shared parent build includes the validation starter and the configuration processor, the shared test library includes the parameterised context test, and the deployment pipeline includes the metadata key check and the diff view. A service then gets most of the standard by upgrading its parent version.

We roll out in order of value: first the metadata check and the CI context start, which find problems without any code change, then @Validated constraints added team by team, starting with services that had configuration incidents. Tracking how many services pass each layer gives a simple progress measure.

7Follow-up questions

Why not just rely on startup validation in a staging environment?

Staging only tests staging values. The production values differ, which is exactly where the mistakes are, so the check must run against each environment's own configuration, and CI is the place to do that before anything is deployed.

How do you handle secrets in the CI context start?

Use placeholder values for secret properties in CI, since we validate presence and format, not the real credential. The deployment configuration references the secret, and the CI job checks that the reference exists while supplying a dummy value of the right shape.

What about configuration from a config server?

The same idea applies: fetch the environment's configuration from the server's backing repository at the commit being deployed and feed it into the CI context start. If that is impractical, it is another argument for keeping configuration in files that CI can read directly.

8Conclusion

In this answer, we built a fleet-wide validation standard in layers. Typed @ConfigurationProperties classes with @Validated make bad values fail fast at startup rather than at first use; a CI step starts the context with each environment's configuration to catch the same errors before deploy; the configuration metadata detects unknown and deprecated keys that validation cannot see; and reviewing per-environment configuration diffs catches changes that are valid but unintended. Delivering all of it through the shared build, test library and pipeline makes it the default for every service.

What to say in the interviewAbout 90 seconds aloud

Open with

I would build it in layers, because no single check catches everything. The base is in the code. All typed configuration goes into @ConfigurationProperties classes with @Validated and constraints like @NotBlank, @Min, @Max and @URL, plus @Valid on nested groups.

Then, if they want more

Bad values then fail fast at startup with a message naming the property and its origin, instead of failing at first use. I would also avoid lazy creation of configuration-dependent beans. Then I move that check before deploy.

A CI job starts the application context once per environment with that environment's real configuration files, but only the properties classes or with external systems stubbed, so it is quick and needs no real database. A bad production value then fails the pull request. Validation cannot see misspelt keys, so the third layer uses the configuration metadata from spring-boot-configuration-processor.

CI compares every key in each environment's values against the known properties and fails on unknown keys or warns on deprecated ones. Fourth, each release shows the configuration diff per environment, so reviewers can spot valid but unintended changes like a timeout going from three seconds to three hundred.

The platform team ships all of this in the shared build, test library and pipeline. We roll out the checks that need no code first and track progress per service.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How would you standardise configuration validation across all services so that...": https://scrivio-interview-library.netlify.app/spring-boot/externalized-configuration/6fc00f42f0/