test-fullautomation / python-jsonpreprocessor

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

Slicing shall be blocked #205

Closed HolQue closed 4 weeks ago

HolQue commented 4 months ago

Hi Thomas,

based on one of our latest discussions, my understanding now is that slicing shall not be supported (even in case of it's already working partially).

Therefore possibly ongoing development should be stopped.

And slicing notation inside square brackets has to cause a corresponding error message.

Reference:

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/184#issuecomment-1918354577

test-fullautomation commented 4 months ago

Hi Son, as Holger writes I decided yesterday that we don't support slicing. Maybe later we will no, but not now. Reaons:

  1. first we should be free of existing issues.
  2. rare use case
  3. much effort to stabilize (e.g. can have nested parameters, ...

So, please create an error message in case you find a slicing operator or a negative index (e.g. ${list}[-1]). Please consider that the negative index can be provided as parameter. E.g. ${list}[${index}] where the value behind ${index} is negative.

Positive operator ${list}[+1] must be allowed. Currently there is a bug. This causes that the whole expression is not resolved.

Thank you, Thomas

HolQue commented 3 months ago

Self test: added JPP_1350 - JPP_1364 (topic: slicing; tests commented out)

namsonx commented 3 months ago

Hello Holger, Hello Thomas,

I created the commit 48eae0f0df on stabi branch.

I aslo enabled the 2 test cases JPP_1350 - JPP_1364

Thank you, Son

HolQue commented 3 months ago

Hi Son,

in one of my commits I wrote: "JPP_1350 - JPP_1364". And the meaning of this is: "from JPP_1350 to JPP_1364", and not: "JPP_1350 and JPP_1364".

All further test cases between 1650 and 1364 are still commented out - and cause errors when I activate them.

But to fix the remaining aspects is for 0.12.x.

HolQue commented 3 months ago

Example:

'Expression '${listParam}[:]' cannot be evaluated. Reason: Empty or special character is detected in pair of square brackets.'

Expected: Slicing is not supported

"testParam" : {"key" : ${listParam}[:]}

still causes

Expecting ',' delimiter: line 5 column 1 (char 75)'

namsonx commented 2 months ago

Hello Holger,

All blocked slicing's test cases are uncovered and tested successful.

Thank you, Son

HolQue commented 2 months ago

Hi Son,

please keep in mind that there is at least one error message active that mentions the possibility to use slices:

'Could not set variable '${testlist}['${intval}']' with value '4'! Reason: list indices must be integers or slices, not str'

That is misleading for the audience, because slicing shall be blocked. In this case you cannot take over the error message from Python.

namsonx commented 2 months ago

Hello Holger,

Could you please check error message again, I updated error message as Thomas' suggestion: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/186#issuecomment-1887111574

Thank you, Son

HolQue commented 1 month ago

Hi Son,

I still get this error message with slicing proposed:

Error: 'Could not set variable '${listP}['${indexP}']' with value 'newvalue'! Reason: list indices must be integers or slices, not str'!

But "or slices" is not expected.

namsonx commented 1 month ago

Hello Holger,

I updated error message in this case.

Thank you, Son

HolQue commented 1 month ago

Retest successful. Issue can be closed.

test-fullautomation commented 4 weeks ago

Released with RobotFramework AIO 0.12.0