spring-cloud / spring-cloud/spring-cloud-consul

New property `spring.cloud.consul.config.prefixes` doesn't work the same way as the deprecated `spring.cloud.consul.config.prefix`

Open
#903 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
822
Forks
539
Avg merge
9h 31m
Merged PRs (30d)
7

Description

Describe the bug
When migrating our Spring Boot services to 3.5, we also migrate some of our deprecated properties to the new ones.
But there's an issue where consul was not working, consul properties was not loaded even though it's working before.

After tracing & debugging for several hours, turned out it's because the new property spring.cloud.consul.config.prefixes doesn't work the same way as the deprecated spring.cloud.consul.config.prefix when it's set to empty string ""

This works:

spring.cloud.consul.config.prefix=
spring.cloud.consul.config.name=config/my-service

This doesn't:

spring.cloud.consul.config.prefixes=
spring.cloud.consul.config.name=config/my-service

Because the latter will lead to empty context on ConsulPropertySources#generateAutomaticContexts.

Setting the new property with any prefix then empty string, however, works:

spring.cloud.consul.config.prefixes=anything,
spring.cloud.consul.config.name=config/my-service

So the question is:

  1. Is the new property spring.cloud.consul.config.prefixes intended to be never empty?
  2. If spring.cloud.consul.config.prefix is removed later and we want to keep using empty prefix - using ...config.name for the full path, is setting the ....config.prefixes to anything, a correct workaround?

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 at ConsulPropertySources#generateAutomaticContexts and compare how the deprecated prefix and the new prefixes property handle an empty value. Reproduce the two configurations from the issue and determine whether an empty prefixes value should preserve the full path from config.name; done means the intended behavior or workaround is documented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.