Local variable scope leakage

I’m working with Zeebe 8.2. I created a bpmn model that has a subprocess. In this subprocess, I defined a local variable “WaitSeconds” in the “Input” section, and I also defined a service task in the subprocess. The service task can be executed multiple times (in a circle). Whenever the job worker of the service task completes, it provides a new value of “WaitSeconds” to the broker (via the Variables property). I noticed that when the job worker provides the value of “WaitSeconds” that is equal to the variable’s value that the subprocess already has, the scope of the “WaitSeconds” changes to global. For example, suppose that the value of “WaitSeconds” in the subprocess is 20 and the job worker also provides a variable “WaitSeconds” with a value 20. This makes the variable global. Why does this happen? According to the documentation on “Variables | Camunda 8 Docs”, this is a wrong behavior, isn’t it?

I attached to the post a simple BPMN model that shows this effect. You can start it from a desktop modeler. If you set the condition for the “Flow_Circled” of the Gateway as “Counter < 4” then the “MyIntegerValue” becomes global at the final circle when the value of “MyIntegerValue” is 3 and the Intermediate Timer Catch Event assigns it a value 3 again. This timer has the following variable mapping for MyIntegerValue in the output:
if MyIntegerValue < 3 then MyIntegerValue + 1 else MyIntegerValue

However, if you set the condition for the “Flow_Circled” of the Gateway as “Counter < 3” which allows to avoid assigning the same value to “MyIntegerValue” then the variable remains local.

image

TestScopeLeakage_3.bpmn (5.8 KB)
.