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

Add option for raising an error on missing ENV variable #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Brias
Copy link

@Brias Brias commented Jan 4, 2023

This PR implements #22 by adding a raise_if_missing option to the parse_config function.

If raise_if_missing is set to True, a ValueError is raised when the following conditions are met:

  1. The ENV variable is not set
  2. No default is set for the ENV variable

Example:

# ValueError is raised
data: !ENV ${NON_EXISTING_ENV}
# No ValueError is raised
data: !ENV ${NON_EXISTING_ENV:explicit_default_value}

For backwards compatibility, raise_if_missing is set to False by default.

@Brias Brias force-pushed the feature_22_raise_error_if_env_is_missing branch from efe8a09 to 246cd58 Compare July 10, 2023 13:02
@maldoinc
Copy link

maldoinc commented Apr 29, 2024

+1. If anything, should be the default behavior of raise_if_na. Sometimes you just don't have a default value.

@pierec
Copy link

pierec commented Sep 24, 2024

+1, very useful!

@mkaranasou - can we get this merged, once you have a spare moment?

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.

3 participants