Spring Boot configuration property migration lacks rollback on invalid target values
0 reputation · 13 Dec 2020, 14:16 UTC
0 reputation · 13 Dec 2020, 14:16 UTC
Spring Boot 2.4+ automatically migrates deprecated configuration property names to their replacements through ConfigurationPropertyMigrationListener during the EnvironmentPostProcessor phase. Migration rules are declared in META-INF/spring-configuration-metadata.json and execute once per property key per application context initialization.
When a migrated value is invalid for the target property — such as a type mismatch or a missing required prefix — the migration still completes silently. The malformed value remains in the Environment, causing downstream bean creation failures (e.g., BindException) with no automatic reversion to the original deprecated key. There is no public API to inspect which migrations fired, revert applied migrations, or validate the post-migration configuration before the bean factory instantiates.
Spring Boot 3.0+ altered default property source precedence (system environment > application.properties > config imports), so a migrated value from a later source can override an explicit setting from an earlier source. Third-party starters contribute their own migration rules; conflicts are resolved by registration order without a deterministic tiebreaker. Actuator’s /configprops endpoint shows only the merged post-migration state, providing no history of transformations.
Given these behaviors, how can an application reliably detect and recover from a failed upgrade caused by an invalid migrated property value? Is there a supported extension point to snapshot pre-migration state or validate target keys before binding? Can migration precedence be made deterministic across starter and application rules without forking the listener?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.