Skip to content

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?

@mschmill
Copy link

I realize it's a long shot given how long it's been, but I imagine this behavior is more useful than raise_if_na for most use cases. Can we get this reviewed and merged?

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.

5 participants