test-fullautomation / python-jsonpreprocessor

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

Misleading and wrong error message #192

Closed HolQue closed 2 months ago

HolQue commented 5 months ago

The last line of the following code is invalid nonsense:

"dictparam" : {"B" : 2},
"listparam" : ["A", "B"],
${IAMNOTEXISTING.${dictparam}}['${listparam}'] : 3

The error message is:

Error: 'Overwrite the element '${IAMNOTEXISTING.${dictparam}}['${listparam}']' failed! Due to the datatype of '${dictparam}' is '<class 'dict'>'. Only simple data types are allowed to be substituted inside.'!

I can imagine that it's very hard to give guidance in case of such code. Because: How to detect nonsense? There must be any initial piece of (invalid) code that causes the JsonPreprocessor to throw an error. And in this example it's the data type dict, that is not allowed at a certain position. But could also be the listparam, that is not allowed inside square brackets. This is a detail. I like to provide details. But how relevant is this detail if the entire expression is nonsense?

In my opinion the wording in this error message (Overwrite the element ... failed! ...) is misleading. Which element cannot be overwritten? And is it really detectable that there is something valid existing, that cannot be overwritten? I would say: No! Therefore the error message is too specific in this case.

I would prefer a more common version like

Expression "..." cannot be evaluated because of the usage of a not supported data type. The data type of ... is .... Only simple ...

More informations we should not expect from the JsonPreprocessor.

Finally I put the expression in quotes:

"${IAMNOTEXISTING.${dictparam}}['${listparam}']" : 3

Now the error is:

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

This astonishes me. Because there is no bracket mismatch.

Also in this case my expectation would be the error message discussed above:

Expression "..." cannot be evaluated ...

HolQue commented 3 months ago

Retest successful (error message improved). Issue can be closed.

test-fullautomation commented 2 months ago

integrated in RobotFramework AIO 0.11.0