Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multidocument files from config server have the same property name #1778

Closed
spencergibb opened this issue Dec 23, 2020 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@spencergibb
Copy link
Member

#1777 (comment)

@spencergibb spencergibb added this to the 3.0.1 milestone Dec 23, 2020
@spencergibb spencergibb self-assigned this Dec 23, 2020
@spencergibb
Copy link
Member Author

The only workaround is to not use multi-document files.

@kuberr
Copy link

kuberr commented Jan 14, 2021

Spring boot itself handles multi-document .yml files gracefully by appending "(document #1)" etc. to each unique property source's name. It might be a bit naïve of me to ask, but can't this idea be implemented by the config server too?

Here is an example from the log trace, you can see the appended suffix when you scroll all the way to the right:

2021-01-14 13:54:28.232 TRACE 14956 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Skipping inactive property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #2)'
2021-01-14 13:54:28.247 TRACE 14956 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Adding imported property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #1)'
2021-01-14 13:54:28.247 TRACE 14956 --- [           main] o.s.b.c.config.ConfigDataEnvironment     : Adding imported property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #0)'

@spencergibb
Copy link
Member Author

This is already fixed

@ssgtcookie
Copy link

ssgtcookie commented Apr 7, 2021

The only workaround is to not use multi-document files.

Does this mean that the option to use multi-document files is dropped? I think this is one of the neat features in spring.

@spencergibb
Copy link
Member Author

That statement was to mean until the fix was deployed as part of 3.0.1. This is included in spring cloud 2020.0.2

kevcherrington added a commit to kevcherrington/config_repo that referenced this issue Feb 7, 2023
@SweKast999
Copy link

SweKast999 commented May 1, 2024

Using Multi document is not working as expected, I am using spring-cloud-config-server with version 3.1.8 and spring boot 2.7.6. I have 2 use cases where it is not working as expected.

### Usecase1:

application.yml

spring:
   config:
     import:
      - classpath:/config/test.yml

test.yml

my:
   prop1: default
   prop2: default
---
spring:
  config:
    activate:
      on-profile: dev
prop1: dev
prop3: abc

Now when I am running the config server using DEV profile, it is only returning me
prop1: dev prop3: abc
and it is not giving me the common properties defined on the top (i.e my.prop1 and my.prop2). As you can see property names are unique. Can you tell me why the common properties are not included?

### Usecase2:

application.yml

spring:
   config:
     import:
      - classpath:/config/integrations.yml

integrations.yml


emailProviders:
   provider1:
     apiKey: testKey
     endpoint: testEndpoint

Now when I am running the config server using DEV profile, it is not returning me any properties. I am expecting apiKey and endpoint to be returned as they are common properties.

Now if I include on-profile: dev, I get the properties defined in DEV mode. I am not understanding what is happening. Can someone please help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants