nutanix / calm-dsl

Keep Calm and DSL On!
https://nutanix.github.io/calm-dsl/
Apache License 2.0
32 stars 51 forks source link

Decompile fails to escape backslashes in regex strings resulting in incorrect recompile #291

Closed nutken closed 4 months ago

nutken commented 6 months ago

Describe the bug A Simple.multiline type profile variable with a regex validation string including tokens such as \r, \n, \t do not get properly escaped during decompile. Recompiling the generated blueprint results in an incorrect validation string. A subsequent decompile of the recompiled blueprint will result in failure.

Branch/Container Tag v3.7.2.1

To Reproduce Create a BP with a multiline profile variable. Configure a regex validation string which contains tokens such as \r, \n, \t. Decompile blueprint and observe the generated regex value for that variable in the blueprint.py. You will see the tokens are not escaped (ie, \r, \n, \t, etc). Compile generated blueprint and observe the incorrect regex in the GUI. Likewise, decompile this blueprint and observe the decompile fails.

Expected behavior The blueprint should be decompiled such that the resulting output can be compiled to produce a functionally equivalent blueprint.

Findings/Troubleshooting Done If the generated regex string were a raw string, the issue should not occur.

Screenshots Original multi-line field DSL (created with escaped tokens) image Original multi-line field in GUI (token present in regex) image

Decompiled multi-line field DSL(tokens not escaped) image Recompiled multi-line field in GUI (tokens not visible in regex) image

System Configuration: Python 3.11.6 / Mac OS X PC 2023.04 / Calm 3.7.2.1

Additional context Add any other context about the problem here.

dwivediprab commented 4 months ago

Issue is fixed in DSL v3.7.2.2 release, Hence closing it.