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

Environment Variables are matched even though there is no exact match in .env files #1115

Open
jakub-pomykala opened this issue Feb 9, 2024 · 1 comment

Comments

@jakub-pomykala
Copy link
Contributor

I have the following environment variable in a .env file:

mpconfig_lowcase_fattest_env_variable=mpconfiglowcasetestValue

If I lookup smallrye_mp_config_lowcase_FATTEST_env_variable it will match it to the env variable in the .env file but this is incorrect according to the spec.

@radcortez
Copy link
Member

Strictly, yes, but from our experience, env variable lookup should be more relaxed than MP Config defines.

From a user experience standpoint, we observed that users expect a case insensitive behaviour when looking up env variables, especially because you never know which source you are looking for, and containers do not place any restrictions on the names that can be used for env variables. For instance, dotted names are acceptable. In practice, the EnvSource almost works as any other source would. The problem is that you need to be able to match multiple combinations.

The strict behaviour also causes performance issues. While it is certainly possible to support it, (and we did in previous versions), it also comes at a high cost. It requires additional String transformations to look up exactly the expected name. Because the EnvSource is so high in the list of sources, most lookups are required to query it.

The current implementation uses a custom equals with the rules implemented to avoid the String transformations and to optimize the name lookup. Please see:

The RSS and startup time improvements are not from this change alone, but there is some contribution.

MP 7.0 is in the works, so maybe it would be better to just loosen up the spec a bit when looking up env vars.

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

No branches or pull requests

2 participants