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

substitution resulting in cycle in pyhocon==0.3.60 (works in 0.3.59) #300

Open
DannyVarod opened this issue Feb 13, 2023 · 0 comments
Open

Comments

@DannyVarod
Copy link

DannyVarod commented Feb 13, 2023

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.
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