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

ConfigTree.merge_configs fails when one ConfigTree comes from file and another from dict #137

Open
gnhernandez opened this issue Nov 2, 2017 · 3 comments

Comments

@gnhernandez
Copy link

On recent versions of pyhocon the merge_configs methods make reference to the attribute "history" of the ConfigTree. This attribute is set when read from file, but is not set when CofigFactory.from_dict is called. This causes the merge_configs methods to fail when e.g. a file is read and some dictionary of overrides is to be merged on top of the file options.

aalba6675 added a commit to aalba6675/pyhocon that referenced this issue Jan 15, 2018
aalba6675 added a commit to aalba6675/pyhocon that referenced this issue Jan 15, 2018
@tekumara
Copy link

Also experienced this. The error is

AttributeError: 'ConfigTree' object has no attribute 'history'

@tfenne
Copy link

tfenne commented Apr 15, 2018

I'm also running into this. For me it's a little more subtle and appears to be dependent on whether the dict overrides values in some or all sub-trees of the file-based config.

@tfenne
Copy link

tfenne commented Apr 15, 2018

My temporary/hacky workaround for this is to parse the dictionary once using ConfigFactory.from_dict() to ensure any dot.separated keys are handled correctly, then dump it to json and re-parse with ConfigFactory.parse_string(). E.g.

c1 = ConfigFactory.parse_file("some.conf")
c2 = ConfigFactory.from_dict({"foo": 1, "bar.splat": 2})
c2 = ConfigFactory.parse_string(json.dumps(c2))

It's a little hacky, but seems to handle everything and results in a valid config.

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

3 participants