You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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
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
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 inenvironment
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
pydantic-settings
#316, we can probably use theenv_ignore_empty
config option in our new API settings class to prevent this from happening across all variablesThe text was updated successfully, but these errors were encountered: