-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Inside a nested dictionary, at a position where a key name is expected, a dollar operator expression is placed (not within quotes - this is another discussion):
"param" : "value",
"params" : {"001" : {"002" : {
${param} : 1
}
}
}
Here I have doubts. Why should someone do this? What is the expectation here? What is the use case?
We need to define a name at that position. We do not speak about overwriting the value of an already existing parameter in the code above. This is the initial definition of the dictionary.
Plausible for me would be this:
"params" : {"001" : {"002" : {
"param" : 1,
${params.001.002.param} : 2
}
}
}
This works. Value is integer 2.
Maybe I overlook something, but my feeling is that code like in the first code example should be blocked. But the precondition for this is, that it is possible to distinguish between
${param} : 1
and
${params.001.002.param} : 2
while parsing the expression.
Or in other words: Is it possible to detect
- that
${param} : 1is placed within a dictionary and - that in
${param}the scope (params.001.002) ofparamis missing?
Nevertheless. What is the current state?
(1)
This:
"param" : "value",
"params" : {"001" : {"002" : {
${param} : 1
}
}
}
causes:
{'param': 1, 'params': {'001': {'002': {'param': 1}}}}
This is dangerous in my opinion, because an assignment within the dictionary has an impact on a parameter outside this dictionary.
And the key name is the name of the used parameter. This means, inside the dictionary the ${} has no effect and is removed only.
(2)
And this:
"params" : {"001" : {"002" : {
${IAMNOTEXISTING} : 1
}
}
}
causes:
{'IAMNOTEXISTING': 1, 'params': {'001': {'002': {'IAMNOTEXISTING': 1}}}}
Also here the scopes are not separated strictly. Because both is created a single parameter with name 'IAMNOTEXISTING' and also a key with this name inside the dictionary.
The behavior of the JsonPreprocessor is dubious in this case.
How to handle this?
Metadata
Metadata
Assignees
Labels
Projects
Status