pyhocon
pyhocon copied to clipboard
substitution resulting in cycle in pyhocon==0.3.60 (works in 0.3.59)
Recreation:
local.conf
:
conf: {
kafka_config: {
# added quotes here so that the keys won't be split into objects on dots
# i.e. bootstrap.servers=value not bootstrap { servers=value }
# keys are unquoted by code in ConfigLoader
"bootstrap.servers": "kafka:9092"
}
kafka_producer_config: ${conf.kafka_config}
kafka_producer_config: {
"request.timeout.ms": 30000
"connections.max.idle.ms": 1800000
}
}
env-overrides.conf
(in same folder as above file):
include "local.conf"
conf: {
kafka_config: {
"bootstrap.servers": "other-kafka:9092"
}
kafka_producer_config: ${conf.kafka_config}
kafka_producer_config: ${conf.kafka_producer_config}
}
Python code:
ConfigFactory.parse_file('path_to_env-overrides.conf')
Error:
in load
config = ConfigFactory.parse_file(str(override_path))
File "/usr/local/lib/python3.7/site-packages/pyhocon/config_parser.py", line 142, in parse_file
return cls.parse_string(content, os.path.dirname(filename), resolve, unresolved_value)
File "/usr/local/lib/python3.7/site-packages/pyhocon/config_parser.py", line 192, in parse_string
return ConfigParser().parse(content, basedir, resolve, unresolved_value)
File "/usr/local/lib/python3.7/site-packages/pyhocon/config_parser.py", line 460, in parse
has_unresolved = cls.resolve_substitutions(config, allow_unresolved)
File "/usr/local/lib/python3.7/site-packages/pyhocon/config_parser.py", line 699, in resolve_substitutions
col=col(substitution.loc, substitution.instring)) for substitution in substitutions)))
pyhocon.exceptions.ConfigSubstitutionException: Cannot resolve ${conf.kafka_consumer_config}: (line: 12, col: 26), ${conf.kafka_producer_config}: (line: 14, col: 26). Check for cycles.