test-fullautomation / python-jsonpreprocessor

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

Error message (11) #261

Open HolQue opened 1 month ago

HolQue commented 1 month ago

Syntax error, caused by missing brackets:

"listparam" : ["A","B","C"],
"param" : ${${listparam}[0]

Error message:

'Invalid parameter format: ${${listparam}[0] - Closed curly bracket is missing.'

That is correct, but the same expression encapsulated in quotes now:

"param" : "${${listparam}[0]"

causes:

'Invalid syntax! One or more than one opened or closed curly bracket is missing in expression '${${listparam}[0]'.'

This is also correct. But why is the wording different? It's the same issue and this is independent from quotes.

This should be aligned. And I would prefer the second error message. Because "Invalid syntax" is in my opinion more meaningful and plausible than "Invalid parameter format" in case of missing brackets.

Other aspect:

You implement the check

if sInput.count("${") > sInput.count("}"):

in two different elif cases. Is it maybe possible to merge this? If not, you should think about a separate method to do this check. Then you would have no need any more to maintain the error message at two different positions in your code and deviations like described above, would not happen any more.

Other aspect:

Because of the '>'

within

if sInput.count("${") > sInput.count("}"):

it can only be detected that there are more opening elements inside an expression than closing elements. And this is correct. Other way round (e.g.: "${param}}}") would not be an error.

But then this part of the second error message is wrong:

One or more than one opened or closed curly bracket is missing

Has to be:

One or more than one closed curly bracket is missing