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

API does not error out/apply default for environment variable set to empty string #411

Open
alyssadai opened this issue Feb 13, 2025 · 1 comment
Assignees

Comments

@alyssadai
Copy link
Contributor

alyssadai commented Feb 13, 2025

For our required environment variables in the n-API, e.g., NB_GRAPH_USERNAME, we have a startup checks that they are set using syntax like the following:

api/app/main.py

Lines 99 to 100 in 3718200

os.environ.get(util.GRAPH_USERNAME.name) is None
or os.environ.get(util.GRAPH_PASSWORD.name) is None

However, this check only works if the variable does not exist in the environment at all, and does not catch cases where the variable exists but is set to an empty string "" (such as the default docker compose behaviour if an interpolated variable defined in environment is unset).

More sneakily, this docker compose behaviour also affects other environment variables that are optional but which we expect to apply the n-API to apply a sensible default for, such as NB_MIN_CELL_SIZE. Since docker-compose.yml does not assign a default value, this variable is automatically set to "", meaning that the API no longer detects it as being unset. This results in unpredictable values for variables inside the n-API.

Steps to resolve

@alyssadai alyssadai moved this to Implement - Active in Neurobagel Feb 13, 2025
@alyssadai alyssadai self-assigned this Feb 13, 2025
@alyssadai alyssadai changed the title API does not error out/apply default for environment variables set to empty string API does not error out/apply default for environment variable set to empty string Feb 14, 2025
@alyssadai alyssadai moved this from Implement - Active to Implement - Done in Neurobagel Feb 14, 2025
@alyssadai alyssadai moved this from Implement - Done to Implement - Track in Neurobagel Feb 14, 2025
@alyssadai
Copy link
Contributor Author

Blocked by #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Implement - Track
Development

No branches or pull requests

1 participant