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

Self-referential substitutions fail if key is a path #87

Open
gilles-duboscq opened this issue May 27, 2016 · 2 comments
Open

Self-referential substitutions fail if key is a path #87

gilles-duboscq opened this issue May 27, 2016 · 2 comments

Comments

@gilles-duboscq
Copy link
Contributor

As reported in #35 these 2 examples fail:

a.b.c += "foo"
a.b.c = ${?a.b.c} ["foo"]

(to see the actual exceptions, this first patch is necessary:

diff --git a/pyhocon/config_parser.py b/pyhocon/config_parser.py
index 9e20236..f29869c 100644
--- a/pyhocon/config_parser.py
+++ b/pyhocon/config_parser.py
@@ -510,10 +510,10 @@ class ConfigTreeParser(TokenConverter):
                 else:
                     value = values[0]
                     if isinstance(value, list) and operator == "+=":
-                        value = ConfigValues([ConfigSubstitution(key, True, '', False, loc), value], False, loc)
+                        value = ConfigValues([ConfigSubstitution(key, True, '', instring, loc), value], False, loc)
                         config_tree.put(key, value, False)
                     elif isinstance(value, str) and operator == "+=":
-                        value = ConfigValues([ConfigSubstitution(key, True, '', True, loc), ' ' + value], True, loc)
+                        value = ConfigValues([ConfigSubstitution(key, True, '', instring, loc), ' ' + value], True, loc)
                         config_tree.put(key, value, False)
                     elif isinstance(value, list):
                         config_tree.put(key, value, False)

)

@mtueng
Copy link

mtueng commented Nov 16, 2017

There are also these related issues:

Issue 1

foo.bar = [1, 2]
foo.bar = ${foo.bar} [3, 4]

Parsing this config fails with this error:
pyhocon.exceptions.ConfigSubstitutionException: Cannot resolve ${foo.bar}: (line: 2, col: 11). Check for cycles.

Issue 2

foo.bar = [1, 2]
foo.bar += [3, 4]

Parsing this config fails with this error:
AttributeError: 'bool' object has no attribute 'count'

Issue 3

foo.bar = [1, 2]
foo {
    bar += [3, 4]
}

Parsing this config results in this unexpected config:

{
  "foo": {
    "bar": [
      3,
      4
    ]
  }
}

Expected is this config:

{
  "foo": {
    "bar": [
      1,
      2,
      3,
      4
    ]
  }
}

@ChouchouDev
Copy link

Similar here:

default {
setting {
format: "file"
}
},
setting-specific: {
setting: ${default.setting},
setting.mode: append
}

The expected output for setting-specific is:
`
ConfigTree([('setting',
ConfigTree([('format', 'file'),
('mode', 'append')]))]))])

But, it lost the param 'format':

ConfigTree([('setting', ConfigTree([('mode', 'append')]))]))]

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