Skip to content

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

@NaldoRay

Description

@NaldoRay

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions