spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.94k stars 1.28k forks source link

Problem of overrides ordering with spring.config.import #2422

Open mehdikhelif opened 1 month ago

mehdikhelif commented 1 month ago

Describe the bug When updating to spring boot 3.2.5 and spring cloud 2023.0.1, we discovered that ordering of property sources was not anymore the same. We are using overrides to "enforce" some configurations shared across multiple microservices. So we are expecting overrides to always have precedence over configuration declared by any microservice.

Since commit https://github.com/spring-cloud/spring-cloud-config/commit/6ec9c432cb2c02840b85fdd8bcd0859eabc0ba46 , the overrides can be overridden by services configuration.

So if we have for example a service with default configuration file and profile 'dev' activated, we used to have this order of property sources:

  1. overrides
  2. service-dev.yaml
  3. service.yaml
  4. classpath: application.yaml

Now, after the update we have this:

  1. service-dev.yaml
  2. service.yaml
  3. overrides
  4. classpath: application.yaml

This is quite similar to the problem exposed in this ticket : https://github.com/spring-cloud/spring-cloud-config/issues/2392

The workaround proposed in the ticket works so using bootstrap starter kind of solves the issue. However, we have the feeling that this is not aligned with the documentation.