Skip to content

Allow properties migrator to fail application startup - #51855

Merged
philwebb merged 2 commits into
spring-projects:mainfrom
noojung:gh-40435
Sep 26, 2026
Merged

philwebb merged 2 commits into
spring-projects:mainfrom
noojung:gh-40435

Conversation

@noojung

@noojung noojung commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

This PR adds a spring.tools.properties-migrator.fail-on property that allows the properties migrator to prevent the application from starting when configuration keys that need to be migrated are found.

As suggested in #40435, a single property is used, with the following values:

  • none (default): preserve the existing migration and reporting behavior.
  • error: fail when keys that are no longer supported are found.
  • warning: fail when keys that have been renamed or are no longer supported are found.

The migration report is still logged regardless of this setting.

See #40435

@noojung noojung changed the title Allow properties migrator to fail application startup Add property to fail application startup when properties need migration Sep 24, 2026
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 24, 2026
@noojung noojung changed the title Add property to fail application startup when properties need migration Allow properties migrator to fail application startup Sep 24, 2026

private static final Log logger = LogFactory.getLog(PropertiesMigrationListener.class);

private static final String FAIL_ON_PROPERTY = "spring.tools.properties-migrator.fail-on";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With an explicit value for the "don't fail case" (which I think is an improvement over the proposal in #40435), I think we need a different property name. fail-on: none doesn't read very well. Does it mean never fail or fail when there are no warnings or errors?

How about fail with values never, on-error, and on-warning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review.

That's a good point. I also think fail-on: none could be confusing, and your suggested names make the behavior clearer. I've updated the property to fail with never, on-error, and on-warning as suggested.

Could you please take another look?


private static final Log logger = LogFactory.getLog(PropertiesMigrationListener.class);

private static final String FAIL_ON_PROPERTY = "spring.tools.properties-migrator.fail-on";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also think about the prefix as we generally try to avoid - characters in prefixes. Rather than spring.tools.properties-migrator, perhaps spring.tools.properties.migrator.

There's also an outside change that we may want other properties that control property handling (the escape hatch mentioned in #27582 (comment) for example) and those should perhaps be grouped together. spring.properties.migrator might be better in that context and then we could have other spring.properties.* properties for related settings.

No need to change anything at this point @noojung, but we'll have to consider this before merging.

@noojung
noojung requested a review from wilkinsona September 25, 2026 09:00
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 25, 2026
@philwebb philwebb self-assigned this Sep 25, 2026
@philwebb philwebb added this to the 4.2.x milestone Sep 25, 2026
noojung and others added 2 commits September 25, 2026 20:23
Add a new configuration property to prevent the application from
starting when configuration keys that need to be migrated are
found.

With `on-error`, the application fails when keys that are no longer
supported are found. With `on-warning`, it also fails when keys that
have been renamed are found. The default, `never`, keeps the current
behavior of only logging the report.

See spring-projectsgh-51855

Signed-off-by: Hyunwoo Jung <hyunwoojung@kakao.com>
@philwebb
philwebb merged commit ef67de0 into spring-projects:main Sep 26, 2026
2 of 3 checks passed
@philwebb

Copy link
Copy Markdown
Member

Thanks very much @noojung, I've changed the property to spring.properties.migrator.fail and merged this into main.

@philwebb philwebb modified the milestones: 4.2.x, 4.2.0-RC1 Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants