Skip to content

Fix env vars for camelCase settings - #797

Open
mmeier86 wants to merge 1 commit into
yacy:masterfrom
mmeier86:fix-camel-case-env-variables
Open

Fix env vars for camelCase settings#797
mmeier86 wants to merge 1 commit into
yacy:masterfrom
mmeier86:fix-camel-case-env-variables

Conversation

@mmeier86

@mmeier86 mmeier86 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Hi YaCy team,

This PR relates to #794

While setting up YaCy with the Docker image in my k8s cluster, I found that environment variables only work for settings like server.https, which consist of all lower letters (and dots) only. But for settings like browserPopUpTrigger, the environment variable YACY_BROWSERPOPUPTRIGGER would be ignored.

It turns out that that that's because during setup, the environment variable is changed to all lower case to find the related config key, and that doesn't work for camelCase keys, as they aren't found.

This PR fixes the issue. As we can't derive camelCase names from the all-caps names of the environment variables, I decided to rewrite the loops a bit. I'm now looping over all entries in the configProps map, and check for each entry whether there is a corresponding env variable or system property. To not iterate over all configs twice, once for env variables and once for system properties, I combined them into the same loop. The order of precedence, with env variables overwriting system properties, is preserved.

One question I've got: I will admit that I haven't worked with Java applications in a very long time, but is checking the System properties actually useful here? Are those generally used for settings when deploying an app?

I've done some local testing with this commit, checking whether camelCase settings now work, and whether all.lower.cased settings still work, and both succeeded.

This commits fixes environment variable handling for YaCy settings which
have camelCase names.

Before this commit, environment variables were only working for settings
with all lower case names. Trying to set values like browserPopUpTrigger
through YACY_BROWSERPOPUPTRIGGER would not work, because the code would
transform the env variable to "browserpopuptrigger", which would then
not be found in the config values, and hence the variable setting would
be skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant