-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fail early on interpolation to self or to ancestor node #662
Comments
${}
interpolation${}
interpolation
Okay, so now I get what
We have since added the ability to access the config root when defining custom resolvers by passing |
It looks like it was added as part of #597. a: 0
b: 1
c: 2
_meta:
cfg_keys: ${oc.dict.keys:${}} |
Yes, there are cases where it can be useful. but I am not sure it's worth the added risk. Since most of the badness begin when a node interpolation resolves to a parent of that node in general (not just in the case of the root node), we may just prevent such interpolations with an early error. a:
# absolute
a: ${}
b: ${a}
c: ${a.c}
# relative
d: ${.}
e: ${..}
f: ${..a}
g: ${..a.g} If think it can be pretty straight forward to detect the condition when a interpolation is pointing to a node that is either the declaring node or a parent of it. Arguably, we can still support it if we do not perform the validation when resolving an interpolation inside a custom resolver, but I would lean toward simpler behavior until we see a really strong use case that would justify an exception. |
${}
interpolation
I took a quick look. I got something basic that works, but it triggers on custom resolvers. I got some initial success detecting that a node resolves to a parent of itself.
(although I think we can detect it while resolving the interpolation). |
It's also possible that:
==> to me performing the dection during resolution makes more sense Here's an example of the second case: data:
target: .a
a: 0
x: ${${.target}} If you now set |
I think airtight detection will be extremely difficult wit custom resolvers and nested interpolations and I am okay with not detecting all cases. if we can catch the common cases it's already much better. |
Ok -- the other potential issue I can see with doing it on creation / mutation and not on access is that a config may go through invalid states while doing a sequence of operations on it, and if we crash as soon as we detect a problem there may be false positives (if subsequent operations were meant to bring the config in a valid state). I'm not sure to which extent this could be a major issue though -- just flagging it as an FYI. |
Using the interpolation
${}
should be illegal because it necessarily causes cycles in the config object.For example, the following config is pathological:
{"x": "${}"}
.Based on a comment originally posted by @omry in #661 (comment)
The text was updated successfully, but these errors were encountered: