You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Version 4.0.4, unable to connect to Cloud Config if we have cloud config profile and spring environment profile. #2349
We have a profile property to connect to cloud config.(spring.cloud.config.profile)
with spring-cloud-config-client-4.0.4.jar, in class ConfigServicePropertySourceLocator, there is a new method which combines profile from property and environment with comma separated.
So, finally profile value while connecting to cloud config will be like below and failing cloud config call.
Even though profile properties are overrider at line 122 ConfigClientProperties properties = this.defaultProperties.override(environment);
in the next line, profile value is getting updated by appending with all the profiles
properties.setProfile(String.join(",", combineProfiles(properties, environment)));
So in method getRemoteEnvironment, while preparing the URL, profile path param is goign as comma separated and there by causing issue.
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
I am preparing a sample with out exposing specific details.
But issue gist is,
1.Spring allows multiple profiles
2.At line 116, properties.setProfile(String.join(",", combineProfiles(properties, environment)));
profile can be comma separated.
3.And we are sending this profile as a path parameter to a GET call at line 291
response = restTemplate.exchange(uri + path, HttpMethod.GET, entity, Environment.class, args);
where args is either = new String[] { name, profile }; or new String[] { name, profile, label };
So, we are ending up having a comma separated URL in a Http GET call
Here is an example. You can run below project as a Spring Boot application.
I have one profile defined for logging.("logging-profile")
I have properties to connect to spring cloud to download properties on startup.(config profile="CONFIG_PROFILE")
So, I have two profiles, one at environment level and one for cloud profile.
changed the title [-]Version 4.0.4, unable to connect to App Config if we have app config profile and spring environment profile.[/-][+]Version 4.0.4, unable to connect to Cloud Config if we have cloud config profile and spring environment profile.[/+]on Nov 9, 2023
If you set spring.cloud.config.profile it should override any profile(s) set in any other manor. So in your example if you set spring.cloud.config.profile=CONFIG_LABEL and set spring.profiles.active=logging-profile the request made to the config server should only have the CONFIG_LABEL profile, ie http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL. Is that correct?
Activity
ryanjbaxter commentedon Nov 7, 2023
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
adityakiranpendyala commentedon Nov 8, 2023
Hi @ryanjbaxter ,
I am preparing a sample with out exposing specific details.
But issue gist is,
1.Spring allows multiple profiles
2.At line 116, properties.setProfile(String.join(",", combineProfiles(properties, environment)));
profile can be comma separated.
3.And we are sending this profile as a path parameter to a GET call at line 291
response = restTemplate.exchange(uri + path, HttpMethod.GET, entity, Environment.class, args);
where args is either = new String[] { name, profile }; or new String[] { name, profile, label };
So, we are ending up having a comma separated URL in a Http GET call
FILE: ConfigServicePropertySourceLocator.java
adityakiranpendyala commentedon Nov 9, 2023
Hi @ryanjbaxter ,
Here is an example. You can run below project as a Spring Boot application.
So, I have two profiles, one at environment level and one for cloud profile.
spring.cloud.config:
name: CONFIG_NAME
uri: http://localhost:8000/properties
label: CONFIG_LABEL
profile: CONFIG_PROFILE
enabled: false
failFast: true
Now when I am starting application, I am getting URL as profiles with comma separated and failing.
demo.zip
GET request for "http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL
[-]Version 4.0.4, unable to connect to App Config if we have app config profile and spring environment profile.[/-][+]Version 4.0.4, unable to connect to Cloud Config if we have cloud config profile and spring environment profile.[/+]ryanjbaxter commentedon Nov 15, 2023
I think I understand what you are saying now...
If you set
spring.cloud.config.profileit should override any profile(s) set in any other manor. So in your example if you setspring.cloud.config.profile=CONFIG_LABELand setspring.profiles.active=logging-profilethe request made to the config server should only have theCONFIG_LABELprofile, iehttp://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL. Is that correct?Do not combine profiles when spring.cloud.config.pofiles is set.
adityakiranpendyala commentedon Nov 15, 2023
yes @ryanjbaxter , your understanding is correct.
Config Service URL should be http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL
but now it is preparing as http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL
Do not combine profiles when spring.cloud.config.pofiles is set.
Do not combine profiles when spring.cloud.config.pofiles is set. (#2354)