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

Scoold Config Environment Variables aren't case insensitive #452

Closed
mljohns89 opened this issue Apr 20, 2024 · 1 comment
Closed

Scoold Config Environment Variables aren't case insensitive #452

mljohns89 opened this issue Apr 20, 2024 · 1 comment

Comments

@mljohns89
Copy link

I just realized that when setting the Scoold config via ENV variables, scoold config expects them to be in lower case.

Standard convention for ENV variables is upper case.

Looking at the code, it looks like this might be an issue for both Scoold and Para since Scoold uses the Para Config class: https://github.com/Erudika/para/blob/master/para-core/src/main/java/com/erudika/para/core/utils/Config.java#L256

I tested this by trying to set a config para as an ENV variable as both SCOOLD_PARA_SECRET_KEY and scoold_para_secret_key and Scoold was only able to connect to Para when I used the lower case ENV variable.

System.getEnv(string) is case sensitive based on the platform the application is running on. On Windows, it is not case sensitive. On Linux and mac it is case sensitive.

The simplest way I can thing to fix this is by changing the above line to something like this:

Optional.of(System.getenv(var10000 + "_" + key.replaceAll("\\.", "_")))
			.orElse(System.getenv(var10000.toUpperCase() + "_" + key.toUpperCase().replaceAll("\\.", "_")))

Let me know your thoughts

@albogdano
Copy link
Member

Thanks for the suggestion, Michael! I changed that line in Config.java to first load the uppercase variable and then default to the lower case one, if it has any value at all.

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

No branches or pull requests

2 participants