test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Error handling deviation #219

Open HolQue opened 3 months ago

HolQue commented 3 months ago

JSON code:

"keyP"   : "A",
"dictP"  : {"A" : 1, "B" : 2},
"newparam" : "${dictP['${indexP}']}"

Result:

'Invalid syntax! One or more than one opened or closed curly bracket is missing in expression '${dictP['${indexP}']}'.
           Please check the configuration file of the executed test!'

Yes, the syntax is invalid. But not because of missing brackets. There are no brackets missing.

The syntax violation is the index placed within the curly brackets (instead of outside).

Same expression moved to the left hand side of the colon:

"${dictP['${indexP}']}" : "newvalue"

Result:

'Invalid syntax: Found index or sub-element inside curly brackets in the parameter '${dictP['str(${indexP})']}''

Now the root cause of the error is detected. But the error message contains a type cast (str(${indexP})) that is not part of the expression.

It is interesting to see, that the error handling is so much different depending on the position of the invalid expression.

It would be better to have the behavior aligned.