test-fullautomation / python-jsonpreprocessor

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

JsonPreprocessor freezes #226

Closed HolQue closed 2 months ago

HolQue commented 3 months ago

Hi Son,

with latest bugfix

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/195#issuecomment-1975020184

the JsonPreprocessor freezes with this JSON code:

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

Expected: newparam has value '1'

namsonx commented 3 months ago

Hello Holger,

I don't think the expected result of parameter newparam is '1', as current JP behavior, the value "${dictP['${keyP}']}" will convert ${dictP['${keyP}']} to string. In this case, it will convert "B" to string, and the result is still "B"

Thank you, Son

HolQue commented 3 months ago

Hi Son,

you're right.

And now it seem to me that the syntax in my example is invalid (because of the square brackets inside the curly brackets).

This should be the valid syntax version:

"newparam" : "${dictP}['${keyP}']"

Now newparam is 'B'.

Impact: The expected outcome of"newparam" : "${dictP['${keyP}']}" now would be an error message about an invalid syntax.

HolQue commented 3 months ago

And with this version

"newparam" : "${${dictP}['${keyP}']}"

newparam has string value '1'

:-)

namsonx commented 3 months ago

Hello Holger,

With this version "newparam" : "${${dictP}['${keyP}']}", the value will be converted to "${B}". And ${B} equal 1, so it will convert "${B}" to string '1' :)

I will fix the issue you mentioned above.

Thank you, Son

HolQue commented 3 months ago

Another possibility to freeze the JsonPreprocessor (with valid syntax now):

"keyP"       : "A",
"B"          : "keyP",
"dictP"      : {"A" : "B"},
//
"newparam_1" : "${dictP}['${keyP}']",                  // => "${dictP}['A']" -> 'B'
"newparam_2" : "${${dictP}['${keyP}']}",               // => "${B}"          -> 'keyP'
"newparam_3" : "${${${dictP}['${keyP}']}}",            // => "${keyP}"       -> 'A'
"newparam_4" : "${dictP}['${${${dictP}['${keyP}']}}']" // => "${dictP}['A']" -> !!! freeze !!!
namsonx commented 3 months ago

Hello Holger,

Regarding to your first comment with jsonp file:

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

The value "${dictP['${keyP}']}" is invalid format instead return string "B", it should be "${dictP}['${keyP}']" as we defined before :)

I just want to correct the point above!

Thank you, Son I just want to ci

HolQue commented 3 months ago

Hi Son,

this is what I told in

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/226#issuecomment-1976506063

namsonx commented 3 months ago

Hello Holger,

This ticket was solved on stabi branch!

Thank you, Son

test-fullautomation commented 3 months ago

Hi Holger, the problem occurs again? Thank you, Thomas

HolQue commented 3 months ago

The code samples used above, work now.

But the JsonPreprocessor still freezes.

Now with this (invalid) code:

   "listparam" : ["A","B","C"],
   "param" : "$}${listparam}[0]"
HolQue commented 3 months ago

Caution: The current freeze effect has an impact on the self test of the TestuitesManagement. This test also freezes!

namsonx commented 3 months ago

Hello Holger,

I have just added mechanism to avoid Python run freezes to stabi branch.

For the issue related to invalid code "$}${listparam}[0]", I will check and fix.

Thank you, Son

HolQue commented 3 months ago

Hi Son,

some details w.r.t. freezed TestsuitesManagement test: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/226#issuecomment-1983106596

Freezing is TSM_1200

Affected JSON file:

https://github.com/test-fullautomation/robotframework-testsuitesmanagement/blob/develop/test/testfiles/config/tsm-test_config_composite_expressions_1.jsonp

HolQue commented 3 months ago

Issue w.r.t.

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

is solved. Result is: '$}A'

TSM_1200 still freezes.

namsonx commented 3 months ago

Hello Holger,

I fixed the issue related to TSM_1200 freezes, could you please help me check!

Thank you, Son

HolQue commented 3 months ago

Retest successful. Issue can be closed.

test-fullautomation commented 2 months ago

integrated in RobotFramework AIO 0.11.0