test-fullautomation / python-jsonpreprocessor

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

Error handling deviation (2) #220

Open HolQue opened 4 months ago

HolQue commented 4 months ago

The JSON code

"param1" : "value1",
"param2" : ${param1

results in

'Invalid parameter format in line: ...

The same with

"param1" : "value1",
"param2" : "${param1"

and with

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

and with

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

Yes, the parameter format is invalid - because of a closing curly bracket is missing.

But I wonder why this is not detected. Every '${' requires a corresponding '}'. It's a simple counting of strings.

In other expressions this works fine already:

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

results in

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

When such a 'bracket match' test is already implemented and available, I would expect that this test is applied to every expression.

Addition

Last example without quotes:

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

causes:

'Invalid nested parameter format: ${${listparam}[0] - The double quotes are missing!!!'

But in my opinion the quotes are not really relevant here - and not missing necessarily. The error handling should give more focus on an '${' that has no matching '}'.