Closed HolQue closed 2 months ago
@namsonx : What is the status of this issue?
Hi @namsonx , what is the status of this ticket? Thank you, Thomas
Hello Thomas,
This ticket was solved together with ticket #117 in the pull-request #151
Thank you, Son
Like already mentioned above and in other issues also, the expectation is:
Expected is an error message telling that it's not allowed to replace parameters of composite data types within key names.
Instead of this the error message is:
'Setting value 'value' for parameter 'prefix_[1, 2, 3]_suffix' is not permissible when substituting parameters of composite data types in dictionary key names!'!
This is misleading. Because the main statement of this error message is: It's not permissible to set the value 'value'. But this is not the problem. The root cause of the problem is reduced to an incidental (... when substituting...). But this is the problem.
It makes also no sense to provide the invalid name (prefix_[1, 2, 3]_suffix). Because this name is based on something that is forbidden. No need to mention the outcome of something forbidden.
You should print the original expression ("${param1}_${param2}_suffix") that causes the problem and you should give a clear statement about the reason for the error.
It should also be obvious that this can happen in two cases: dictionary key names and parameter names. The second case is still not handled.
The JSON code
"param1" : [1,2,3],
"param2-${param1}" : 123
causes
'Could not set variable 'param2-[1, 2, 3]' with value '123'! Reason: cannot assign to operator (<string>, line 1)'!
Same issue like above: It is not allowed to replace parameters of composite data types within parameter names.
And the reason "cannot assign to operator
" completely makes no sense in this context.
See also:
https://github.com/test-fullautomation/python-jsonpreprocessor/issues/69#issuecomment-1589575019
See also:
https://github.com/test-fullautomation/python-jsonpreprocessor/issues/69#issuecomment-1708337615
Further aspects:
[1]
Dictionary key names and parameter names have to be handled in code (and therefore in error messages also) separately.
The JSON code
"list" : [1,2,3],
"${list}" : 123
causes:
'Setting value '123' for parameter '[1, 2, 3]' is not permissible when substituting parameters of composite data types in dictionary key names!
That's wrong: "dictionary key names". A dictionary is not involved. It's a simple parameter name, but not a dictionary key name.
[2]
"list" : [1,2,3],
"prefix_${list}" : 123
causes:
Could not set variable 'prefix_[1, 2, 3]' with value '123'! Reason: name 'prefix_' is not defined
Error message is incomplete and wrong. Expected is: It is not allowed to replace parameters of composite data types within parameter names.
[3]
"list" : [1,2,3],
"${list}_suffix" : 123
causes:
Setting value '123' for parameter '[1, 2, 3]_suffix' is not permissible when substituting parameters of composite data types in dictionary key names!
Outcome: There is a difference between error message [2] and [3], depending on if a prefix or a suffix is added to the parameter of not allowed composite data type. But this should not make a difference.
Expected is that the data type of dollar operator expressions is checked with highest priority.
Hello Holger,
I created new commit 422921b4 on stabi branch
The error message now is Exception: Could not substitute parameter '${param1}_${param2}_suffix' due to a composite data types in dictionary key names! The value of parameter '${param2}' is [1, 2, 3]
Thank you, Son
Hi Son,
unfortunately the grammar is not correct. Please use instead:
Exception: Could not substitute parameter '${param1}_${param2}_suffix'! Composite data types are not allowed. The value of parameter '${param2}' is [1, 2, 3]
Thank you, Thomas
Hello Thomas,
Thank you for your comment! I updated and pushed the change to stabi branch.
Thank you, Son
Retest partly successful. Lot's of improvements.
But one issue left.
The code
"list" : [1,2,3],
"${list}_suffix" : 123
causes
Found expression '${list}_suffix' with at least one parameter of composite data type ('${JPavoidDataType_list}' is of type ...
Something went wrong in the error message: ${JPavoidDataType_list}
This does not happen in case of the affected expression (${list}_suffix
) represents a dictionary key instead of a single parameter.
Still open.
Hello Holger,
I pushed the commit 296c9482f86 to stabi branch to update the error message.
Thank you, Son
Hi Son, can this be closed? Thank you, Thomas
Last issue part (https://github.com/test-fullautomation/python-jsonpreprocessor/issues/111#issuecomment-1884817369) also solved.
Issue can be closed.
JSON code:
The expression
"${param1}_${param2}_suffix"
is the name of a dictionary key. And this dictionary is the value of"param3"
.Because of
param2
is a parameter of typelist
, a substitution of${param2}
within this key name is not allowed.The JsonPreprocessor returns the following exception:
This error message is misleading and makes no sense. The problem here is not a missing quote. It seems that the opened curly bracket in
{"${param1}_${param2}_suffix"
is interpreted as part of a value. But it's a JSON syntax element that indicates the beginning of a dictionary definition instead.Expected is an error message telling that it's not allowed to replace parameters of composite data types within key names.
Reference:
https://github.com/test-fullautomation/python-jsonpreprocessor/issues/69#issuecomment-1589581903
and latest JsonPreprocessor test branch.