Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail hard if spring.profiles.include is used with new config processing #22693

Closed
mbhave opened this issue Jul 31, 2020 · 5 comments
Closed

Fail hard if spring.profiles.include is used with new config processing #22693

mbhave opened this issue Jul 31, 2020 · 5 comments
Labels
theme: config-data Issues related to the configuration theme type: enhancement A general enhancement
Milestone

Comments

@mbhave
Copy link
Contributor

mbhave commented Jul 31, 2020

spring.profiles.include and spring.profiles are not used by the new config data code. However, they are still valid if legacy processing is switched on. We should consider if we want to deprecate them in the metadata.

We also need to update the documentation which mentions spring.profiles.include here.

@mbhave mbhave added the for: team-attention An issue we'd like other members of the team to review label Jul 31, 2020
@mbhave mbhave added this to the 2.4.x milestone Jul 31, 2020
@philwebb
Copy link
Member

philwebb commented Aug 3, 2020

We currently still support spring.profiles, but we should log a warning. I think we should update InvalidConfigDataPropertyException to throw an exception if spring.profiles.include is used.

@philwebb philwebb added type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review labels Aug 3, 2020
@mbhave mbhave changed the title Consider marking properties related to legacy config file processing as deprecated Fail hard if spring.profiles.include is used with new config processing Aug 3, 2020
@mbhave mbhave added the theme: config-data Issues related to the configuration theme label Aug 5, 2020
@mbhave mbhave modified the milestones: 2.4.x, 2.4.0-M2 Aug 5, 2020
@mbhave mbhave closed this as completed in b9abcf1 Aug 5, 2020
@perilbrain
Copy link

+1 to @mbhave
Please do a hard fail if spring.profiles.include is used. I had a setup like

  • application.properties.example
  • application-security.properties.example
  • .gitignore
  • application-common_pg.properties
  • application-common.properties
  • application-local_minepg.properties
  • application-local_mine.properties
  • application-local.properties
  • application-prod.properties
  • application.properties
  • application-security.properties
  • application-stage.properties

Where .gitignore ignores has

application-security.properties
application.properties
application-local_*.properties

and every major profile such as prod, stage etc has at top

spring.profiles.include=common,common_pg,security
# ...

In a new project everything was working on local but suddenly blasted on staging. I was unable to figure out the problem until I started debugging the spring boot source code. There I found @Deprecated in spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java which led to a new discovery that spring.profiles.include is deprecated. Now after 5 days of headache I was able to figure this out which is not going to be easier for a new developer.
Better do a hard fail if legacy flags are not available.

@wilkinsona
Copy link
Member

wilkinsona commented Jan 11, 2021

Thanks for sharing your experience, @perilbrain. We started failing hard in 2.4.0.M2 (this issue) but this was then relaxed in 2.4.0.M3 to allow spring.profiles.include to be used in non-profile-specific documents. I've opened #24733 so that we can improve the situation.

@AJMcDee
Copy link

AJMcDee commented Jan 19, 2022

Hi there, I've just come across this exact issue as the other user (only seeing this when pushing to stage!) when updating from a much older version of Spring Boot.

Am I right in thinking that in 99% of cases, updating to spring.profiles.active is the right way to 'include' other properties?

I'm pretty new to Spring Boot configuration/updates so just want to check that I'm on the right track, and also leave a trail for any other noob devs who come across this thread.

@philwebb
Copy link
Member

@AJMcDee It's hard to offer specific advice without more details, but generally speaking the spring.config.import property is a better option if you want to include other property files. This was only introduced in Spring Boot 2.4, so there are still a lot of applications out there that use profiles in order to import additional files. There's some details about this in this blog post. There's also a what's new video that covers some of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: config-data Issues related to the configuration theme type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants