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)
The following should print "hi":
However, instead it throws an error: