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

Index dependency env vars are not honored #34037

Closed
amoscatelli opened this issue Jun 14, 2023 · 9 comments
Closed

Index dependency env vars are not honored #34037

amoscatelli opened this issue Jun 14, 2023 · 9 comments
Labels
area/config kind/bug Something isn't working

Comments

@amoscatelli
Copy link
Contributor

Describe the bug

According to :
https://quarkus.io/guides/all-config

QUARKUS_INDEX_DEPENDENCY__DEPENDENCY_NAME__GROUP_ID
QUARKUS_INDEX_DEPENDENCY__DEPENDENCY_NAME__ARTIFACT_ID

env vars can be used.

Right now, this is not working. An example will follow.

using application.properties is working :

quarkus.index-dependency.problem-details.group-id=com.github.t1
quarkus.index-dependency.problem-details.artifact-id=problem-details-ri

using lower case env vars is working :

quarkus.index-dependency.problem-details.group-id=com.github.t1
quarkus.index-dependency.problem-details.artifact-id=problem-details-ri

using documented upper case env vars is not working :

QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__GROUP_ID=com.github.t1
QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__ARTIFACT_ID=problem-details-ri

Expected behavior

QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__GROUP_ID=com.github.t1
QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__ARTIFACT_ID=problem-details-ri

should be honored

Actual behavior

QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__GROUP_ID=com.github.t1
QUARKUS_INDEX_DEPENDENCY__PROBLEM_DETAILS__ARTIFACT_ID=problem-details-ri

is not honored and the dependency is not added to index

How to Reproduce?

Try to index a dependency using documented environment variables

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

3.1.0 Final

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

No response

Additional information

No response

@amoscatelli amoscatelli added the kind/bug Something isn't working label Jun 14, 2023
@gsmet
Copy link
Member

gsmet commented Jun 15, 2023

Have you tried:

QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_GROUP_ID=com.github.t1
QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_ARTIFACT_ID=problem-details-ri

?

Note that I removed the double underscores.

@mkouba
Copy link
Contributor

mkouba commented Jun 15, 2023

Hm, I agree with @gsmet - according to the docs the quarkus.index-dependency.problem-details.group-id should be translated to QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_GROUP_ID...

@amoscatelli
Copy link
Contributor Author

Have you tried:

QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_GROUP_ID=com.github.t1
QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_ARTIFACT_ID=problem-details-ri

?

Note that I removed the double underscores.

Just tried but it doesn't work.

The only working combinations are in application.properties or envs with lower case style.

@geoand
Copy link
Contributor

geoand commented Jun 27, 2023

cc @radcortez

@radcortez
Copy link
Member

Please check https://quarkus.io/guides/config-reference#environment-variables.

It is simply not possible to correctly map QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_GROUP_ID to its dotted name format, due to the mix-ins of dots and dashes. In these cases, you need to use the dotted name format (could be empty), so we know to which property name you want to refer to:

quarkus.index-dependency."problem-details".group-id=
quarkus.index-dependency."problem-details".artifact-id=

@radcortez radcortez closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
@mkouba
Copy link
Contributor

mkouba commented Jun 28, 2023

Please check https://quarkus.io/guides/config-reference#environment-variables.

It is simply not possible to correctly map QUARKUS_INDEX_DEPENDENCY_PROBLEM_DETAILS_GROUP_ID to its dotted name format, due to the mix-ins of dots and dashes. In these cases, you need to use the dotted name format (could be empty), so we know to which property name you want to refer to:

quarkus.index-dependency."problem-details".group-id=
quarkus.index-dependency."problem-details".artifact-id=

I don't understand how this should work. The doc is clear that config searches several environment variables for a given property name, e.g. for quarkus.index-dependency."problem-details".group-id it should search exact match, replace non-alphanumeric chars with _, etc. In other words, the config does not map an ENV variable to a config property but the other way around, it should attempt to find an ENV variable for a property.

@radcortez Are you talking about the "In some situations, looking up the exact property name is impossible. For instance, when looking up a configuration that is part of a Map, ..." part? If so then maybe we should highlight this part somehow, maybe even extract the paragraph in a separate admonition of type IMPORTANT/CAUTION/WARNING.

WDYT?

@radcortez
Copy link
Member

I don't understand how this should work. The doc is clear that config searches several environment variables for a given property name, e.g. for quarkus.index-dependency."problem-details".group-id it should search exact match, replace non-alphanumeric chars with _, etc. In other words, the config does not map an ENV variable to a config property but the other way around, it should attempt to find an ENV variable for a property.

Yes, but in this case, the segment "problem-details" is dynamic (the Map key). There is no way for us to know which such names in advance to perform the lookup and apply the mapping ENV rules. In these cases, we need to iterate the list of the property names. Now consider:

If we get a single property in the names list from the ENV source QUARKUS_INDEX_DEPENDENCY__DEPENDENCY_NAME__GROUP_ID, how do we remap this back to its original format? The issue is that there is a loss of information because a _ can either be a dot or a dash. For instance, both dotted properties quarkus.index.dependency."dependency-name".group-id and quarkus.index.dependency."dependency.name".group-id have the same environment variable representation. By default, we map the ENV name always with dots, because we don't know where the dashes could be.

Now, if you also include a property quarkus.index.dependency."dependency-name".group-id in any source (can be empty), plus the ENV name, we know have both properties in the list. This will provide us enough information to determine that QUARKUS_INDEX_DEPENDENCY__DEPENDENCY_NAME__GROUP_ID is quarkus.index.dependency."dependency-name".group-id, so now the matching works as expected.

@radcortez Are you talking about the "In some situations, looking up the exact property name is impossible. For instance, when looking up a configuration that is part of a Map, ..." part? If so then maybe we should highlight this part somehow, maybe even extract the paragraph in a separate admonition of type IMPORTANT/CAUTION/WARNING.

Correct.

@mkouba
Copy link
Contributor

mkouba commented Jun 28, 2023

Ok, how about this: #34366 ?

@radcortez
Copy link
Member

Sure. Thanks!

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

5 participants