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

@ConfigMapping behaviour changed in Quarkus 2.16.2 #34208

Closed
luce98 opened this issue Jun 21, 2023 · 2 comments
Closed

@ConfigMapping behaviour changed in Quarkus 2.16.2 #34208

luce98 opened this issue Jun 21, 2023 · 2 comments
Labels
area/config kind/bug Something isn't working

Comments

@luce98
Copy link

luce98 commented Jun 21, 2023

Describe the bug

We have a project with a configuration as the following in the application.yaml:

quarkus:
  mailer:
    username: ${provider-username}
    password: ${provider-password}

...    

provider:
  username: ${provider-api-username}
  password: ${provider-api-password}

with a .env for the secrets.
Then we have a configuration class as the following:

@ConfigMapping(prefix = "provider")
public interface ProviderProps {

    @NotBlank String username();

    @NotBlank String password();
}

When upgrading one of our projects from Quarkus 2.14.2.Final to 2.16.5.Final, something broke.
After looking at the changelog, I see that smallrye-config was upgraded to 2.13.2, in which is present the following change
smallrye/smallrye-config#881
which I believe it is causing the different behaviour.
I don't expect this to be "fixed" because this is probably a right behaviour but maybe a note could be added in the migration guide to pay attention to name .env variables due to possible conflicts.

Expected behavior

ProviderProps.username() returns the value defined in the .env for provider-api-username.

Actual behavior

ProviderProps.username() returns the value defined in the .env for provider-username.

How to Reproduce?

Clone the repository
/~https://github.com/luce98/quarkus-reproduce-config-issue

  1. run the test testConfiguration in class AppConfigTest -> it should pass
  2. change quarkus version to 2.16.2
  3. run the test again -> it should fail

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.2

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

No response

Additional information

No response

@luce98 luce98 added the kind/bug Something isn't working label Jun 21, 2023
@geoand
Copy link
Contributor

geoand commented Jun 21, 2023

cc @radcortez

@radcortez
Copy link
Member

I don't expect this to be "fixed" because this is probably a right behaviour but maybe a note could be added in the migration guide to pay attention to name .env variables due to possible conflicts.

Correct. This was a bug, because .env is treated as an Environment Variable source, but it was possible to set properties without the limitations of environment variables. While this was convenient, it also caused issues, since property names would not match the lookup names when performing the lookup name conversion for an Environment Variable.

I've updated the migration guide: /~https://github.com/quarkusio/quarkus/wiki/Migration-Guide-2.16#config

If you still want to use regular property names and external files for configuration, you can use quarkus.config.locations and point it to an external configuration properties files: https://quarkus.io/guides/all-config#quarkus-core_quarkus.config.locations.

@radcortez radcortez closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants