Skip to content

Conversation

@jdaugherty
Copy link
Contributor

This bug is preventing my application from loading any configuration in development mode because spring.profiles.active is not defined. I'm specifically failing on loading of an application.groovy file without an environment specific configuration.

@jdaugherty
Copy link
Contributor Author

@matrei some of the earlier reports of application.groovy not loading configuration is likely due to this bug.

@jdaugherty
Copy link
Contributor Author

Fixes #15193

@matrei
Copy link
Contributor

matrei commented Oct 31, 2025

I think it might make more sense to change the condition on line 228 instead as springActiveProfile will always be true with this change.

So instead of defaulting springActiveProfile to Environment.current.name, would it work with?:

if (!sourceMapProfile1 && !sourceMapProfile2) {

on line 228?

@jdaugherty
Copy link
Contributor Author

I think it might make more sense to change the condition on line 228 instead as springActiveProfile will always be true with this change.

So instead of defaulting springActiveProfile to Environment.current.name, would it work with?:

if (!sourceMapProfile1 && !sourceMapProfile2) { 

on line 228?

Well, I thought that originally too but if we run boot run its development mode but no profile is set. Shouldn't dev only config apply in that case? Is it valid to not have a profile?

@matrei
Copy link
Contributor

matrei commented Nov 1, 2025

@jdaugherty Does this problem also exist in any of the functional test apps?
Otherwise, could you replicate the problem in a minimal app?
It's not clear to me what's going on.

@jdaugherty
Copy link
Contributor Author

@jdaugherty Does this problem also exist in any of the functional test apps?

Otherwise, could you replicate the problem in a minimal app?

It's not clear to me what's going on.

It won't ever exist in a test because the tests explicitly run with a test profile.

@matrei
Copy link
Contributor

matrei commented Nov 1, 2025

Yes, but you can start the functional-test apps with bootRun.

@jdaugherty
Copy link
Contributor Author

How? The test annotations explicitly set the profile.

My original question is still unanswered: is it valid to not have a profile? Also, shouldn't the profile always be equal to the grails environment?

@jdaugherty
Copy link
Contributor Author

@matrei I misread your original comment, in terms of reproducing with the functional test apps by using their bootRun, let me get back to you.

@jdaugherty
Copy link
Contributor Author

@matrei

To reproduce with a functional test app in grails-core, you can test with issue-11102. The issue is earlier versions of grails recommended this customization to bootRun:

 String springProfilesActive = 'spring.profiles.active' systemProperty springProfilesActive, System.getProperty(springProfilesActive) 

Which maps the profile to an empty string, instead of null. I've updated the PR to use groovy truth to address this scenario.

matrei and others added 3 commits November 1, 2025 23:42
@jdaugherty
Copy link
Contributor Author

@matrei I merged your proposed change. thank you for taking a look at this. I assume you're ok with me merging this then?

@jdaugherty jdaugherty changed the title fix - #15193 if no spring profile is defined, assume the environment fix - #15193 fix empty spring profile causing configuration to not load Nov 2, 2025
@matrei matrei merged commit be995b5 into apache:7.0.x Nov 3, 2025
60 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants