spring-cloud / spring-cloud/spring-cloud-config

Configuration is not resolved properly with profile and label

Open
#2,933 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
2k
Forks
1.3k
Avg merge
2d 59m
Merged PRs (30d)
16

Description

Describe the bug
For some profiles (production), we use the spring.cloud.config.label property, to fetch a specific tag from the Cloud Config server - configured with on-profile property. Despite this, the configuration is read from the master (default) branch instead of the specified tag.

The configuration we use:

---

spring:
  config:
    activate:
      on-profile: epos_prod,epos_rc
  cloud:
    config:
      label: v2.65

When running the application with option -Dspring.profiles.active=rc,epos_rc, the configuration is clearly read from the master (default) branch instead of the specified v2.65 (a property removed after this version is missing). If we explicitly add the -Dspring.cloud.config.label=v2.65 to application Java options, the correct tag is used.

In the log files we can see three entries related to locating the environment:

2025-06-25 15:43:10 INFO  [main] ServerApplication              : [] The following 3 profiles are active: "epos", "rc", "epos_rc"
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Fetching config from server at : http://localhost:9000
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Located environment: name=commons,portal, profiles=[default], label=null, version=1fd890a439796678449be5e345d5249d47070b43, state=
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Fetching config from server at : http://localhost:9000
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Located environment: name=commons,portal, profiles=[epos,rc,epos_rc], label=epos-v2.65, version=7b38f9138627e08fb2e7de08bcf7cfb1e46c7ea6, state=
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Fetching config from server at : http://localhost:9000
2025-06-25 15:43:10 INFO  [main] ConfigServerConfigDataLoader   : [] Located environment: name=commons,portal, profiles=[default], label=epos-v2.65, version=7b38f9138627e08fb2e7de08bcf7cfb1e46c7ea6, state=

When additionally using the -Dspring.cloud.config.label=v2.65 option, the first entry (with profiles=[default], label=null) is not generated.

Used with Spring Boot version: 3.4.4, tested also with 3.4.7.
Worked with previous versions, probably with 3.3.x (why only probably: logs from the time when we were using it have only one entry with "Located environment", but we might not have the differences in cloud config that would make the bug manifest then).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ConfigServerConfigDataLoader entry point named in the logs and trace how profile-specific configuration and the spring.cloud.config.label value are resolved. Compare behavior on Spring Boot 3.4.4 or 3.4.7 with the previous 3.3.x behavior. Done means the configured label is used without the JVM property override, with a regression test covering the reported profile setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java, spring, spring-boot
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.