Braces dissappear

I have the below code snippet added to my script to split a regex.
if (matcher.find()) {
FlightReference = “${matcher.group(0)}”
} else {
println(‘No match found’)
}

It works fine, but whenever I save the testcase from the manual mode the braces {} here: “${matcher.group(0)}” dissappears and the script fails. This only happens if I save from the manual mode. Saving from script mode does not have any issue. Is this a bug?

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

I could reproduce your case on my side.

Yes, it is a bug in Katalon Studio. It is a well-known fossil bug going back 〜8 years.

When you switch from Script to Manual, the Groovy source code is compiled into an Abstract Syntax Tree. When you switch from Manual to Script, Katalon transforms the Abstract Syntax Tree (also known as AST) into a Groovy source code. Unfortunately Katalon Studio has some problems about AST-to-Source transformation. Therefore

  1. the Groovy source you wrote by your hand in the text editor (Script mode)
  2. the Groovy source generated by Katalon Studio when you switch from Manual mode to Script mode

these two codes can not be identical completely.

@jithin found that "${matcher.group(0)}" was changed to "$matcher.group(0)" by Katalon. This is an instance of defect. I think it will be very difficult to fix these problems.

In short, the Manual mode and the Script mode — these are not interchangeable. This fact contradicts the user’s expectations. The official doc never explains this fact.


How to prevent this mess?

If you live with Script mode, then you should never switch to Manual mode. That act corrupts you.

If you live with Manual mode, that’s fine. But you should never cheat on it.

Switching between two modes to and fro confuses you. You should stay in one.


I don’t think Katalon is going to fix it, ever.

He recently wrote

It appears that someone at Katalon never returned from their journey to find the answer to this issue. @devalex88?


Personally, I don’t care this bug because I would never touch the Manual mode.

By the way,

This works:

    FlightReference = "${matcher.group(0)}"

but this doen’t:

    FlightReference = "$matcher.group(0)"

Why? What’s the difference?

The Groovy language documentation clearly explains why. Refer to this section if you like