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

Cannot override list config property in Quarkus 3.17 #44891

Open
fire2 opened this issue Dec 3, 2024 · 7 comments
Open

Cannot override list config property in Quarkus 3.17 #44891

fire2 opened this issue Dec 3, 2024 · 7 comments
Labels
area/config kind/bug-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.

Comments

@fire2
Copy link

fire2 commented Dec 3, 2024

Describe the bug

In Quarkus 3.17, a config property of type list specified in yaml as:

countries:
  - de

cannot be overwritten via system property such as:

mvn compile quarkus:dev -Dcountries=nl

This worked fine in 3.16.x and should work according to the Quarkus documentation.

Expected behavior

List config property can be overwritten as on Quarkus 3.16

Actual behavior

Default value from application.yaml is used instead of value specified in system property. The same behaviour is observed with environment variable, it doesn't override the default value either.

How to Reproduce?

  1. Clone my minimal demo: https://github.com/fire2/quarkus-bug-config-list
  2. Follow the steps on the readme to see breaking change (bug) in 3.17 compared to 3.16.

Output of uname -a or ver

Darwin LPTP2036320 23.6.0 Darwin Kernel Version 23.6.0: Thu Sep 12 23:36:12 PDT 2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6020 arm64

Output of java -version

openjdk version "21.0.1" 2023-10-17 LTS

Quarkus version or git rev

3.17.2

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.6

Additional information

No response

@fire2 fire2 added the kind/bug Something isn't working label Dec 3, 2024
Copy link

quarkus-bot bot commented Dec 3, 2024

/cc @radcortez (config)

@fire2 fire2 changed the title Bug in Quarkus 3.17 when overriding list config property Cannot override list config property in Quarkus 3.17 Dec 3, 2024
@radcortez
Copy link
Member

@fire2 can you please check if #44838 fixes the issue?

Alternatively, you can try: #44811 (comment)

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Dec 3, 2024
@fire2
Copy link
Author

fire2 commented Dec 5, 2024

Explicitly using io.smallrye.config.smallrye-config-source-yaml:3.10.2 with Quarkus 3.17.2 as below didn't solve the issue:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>3.17.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.smallrye.config</groupId>
                <artifactId>smallrye-config-source-yaml</artifactId>
                <version>3.10.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

I confirmed checking the dependency tree that 3.10.2 is being used.

@radcortez
Copy link
Member

It has to be smallrye-config-source-yaml:3.9.x, like 3.9.1.

@fire2
Copy link
Author

fire2 commented Dec 5, 2024

I thought 3.10.2 has the reverted change. Anyways, I tried now with 3.9.1.

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>3.17.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.smallrye.config</groupId>
                <artifactId>smallrye-config-source-yaml</artifactId>
                <version>3.9.1</version>
            </dependency>
        </dependencies>
</dependencyManagement>

And it still doesn't work.

@gsmet
Copy link
Member

gsmet commented Dec 5, 2024

@radcortez FWIW, there's a reproducer attached so you should be able to reduce the feedback loop :).

@radcortez
Copy link
Member

Yes. I was already looking into it. Because the issue seems very similar to #44811, I thought that was the problem. I'm sorry for that.

This is a different case caused by smallrye/smallrye-config#1202. A collection configuration value can be represented as list=foo,bar or list[0]=foo,list[1]=bar. While the first version is convenient, it only really works for simple type elements and not for composed types. The API became a bit inconsistent, so we tried to make things a bit more consistent by prioritizing indexed names when populating collections. (BTW, the indexed and the APIs for collections are a SmallRye Config exclusive feature; MicroProfile Config only deals with simple collection elements and the comma-separated values configuration).

This usually is not a problem because users use only one of the styles, but the YAML source is tricky (also related to #44811). The ConfigSource API forces us to translate a YAML file content to property-base content. In reality, the correct representation of a collection in YAML is the indexed form name[i]. The YAMLConfigSource predates the support of indexed properties, so we indeed flattened and transformed such cases to the comma-separated values (which I wanted to remove in smallrye/smallrye-config#1203.

So, in the end, the YAMLConfigSource provides the indexed format and the comma-separated values format. Because the indexed has priority, to be able to override it, you need to use that format instead (-Dcountries[0]=nl).

I think I have an idea to support the new priority and still make it overrideable with both styles.

@radcortez radcortez added kind/bug-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus. and removed triage/needs-feedback We are waiting for feedback. kind/bug Something isn't working labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.
Projects
None yet
Development

No branches or pull requests

4 participants