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

ConfigParser accept_unresolved option not working #298

Open
ArthurFaisman opened this issue Jan 11, 2023 · 0 comments
Open

ConfigParser accept_unresolved option not working #298

ArthurFaisman opened this issue Jan 11, 2023 · 0 comments

Comments

@ArthurFaisman
Copy link

The following should print "hi":

partially_resolving_config = ConfigFactory.parse_string("""
resolvedVal = "hi"
unresolvedVal = ${valDoesNotExist}
""", resolve=False)

ConfigParser.resolve_substitutions(partially_resolving_config, accept_unresolved=True)

# this should work
print(partially_resolving_config["resolvedVal"])

However, instead it throws an error:

Traceback (most recent call last):
  File "/xx/venv/lib/python3.9/site-packages/pyhocon/config_parser.py", line 538, in _resolve_variable
    return True, config.get(variable)
  File "/xx/venv/lib/python3.9/site-packages/pyhocon/config_tree.py", line 236, in get
    return self._get(ConfigTree.parse_key(key), 0, default)
  File "/xx/venv/lib/python3.9/site-packages/pyhocon/config_tree.py", line 176, in _get
    raise ConfigMissingException(
pyhocon.exceptions.ConfigMissingException: 'No configuration setting found for key valDoesNotExist'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/xx/config_test.py", line 24, in <module>
    ConfigParser.resolve_substitutions(partially_resolving_config, accept_unresolved=True)
  File "/xx/venv/lib/python3.9/site-packages/pyhocon/config_parser.py", line 703, in resolve_substitutions
    is_optional_resolved, resolved_value = cls._resolve_variable(config, substitution, accept_unresolved)
  File "/xx/venv/lib/python3.9/site-packages/pyhocon/config_parser.py", line 547, in _resolve_variable
    raise ConfigSubstitutionException(
pyhocon.exceptions.ConfigSubstitutionException: Cannot resolve variable ${valDoesNotExist} (line: 3, col: 17)
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

No branches or pull requests

1 participant