Operate Connector issue with variable/search -> missing backslashes for value filter

Hello there,
i have the following issue with the Camunda Operate Connector (Connectors 22.1(latest) and SNAPSHOT):

Im trying to search if a processInstance is already created once or more with the operate Endpoint → variables/search. The response is always 0 because the Operate Connector doesnt insert backslashes to the search body.

The Value is given with the start of the Processinstance as a JSON String:

2023-08-28 14_53_18-Camunda Modeler

Im using the following Filter in the Connector:

But the Connector is building the body not with backslashes in Operate and the result is zero:

When im searching in Swagger with the Backslashes in the value the result is correct:

2023-08-28 14_31_18-Swagger UI

Im not able to insert backslahes in the modeler before and after the value. How can i pass a processVariable into the value search field of the variables/search Endpoint in the Operate Connector?

Try starting your process with:

{
   "TEST_KEY":"\"ThisIsATestKey"\"
}

Do you want the value of TEST_KEY to be ThisIsATestKey or "ThisIsATestKey" (with or without double quotes)?

Your first two screenshots show the value as ThisIsATestKey (without double quotes). Based on those two alone, I would expect the search to work. The Swagger screenshot is searching for a value of "ThisIsATestKey" (with double quotes). Which one is your intended value?

The value is set from an Kafka Consumer Connector in the final version and looks like i send it in the local process (first Screenshot) and is also shown in Operate in this format. I want to take this variable and set it in the Camunda Operate Connector to verify, if only one Instance is and was created weith this Key. Its not possible to publish this value double quoted in my Kafka topic, because this Key ist also used for other Tasks.
When im using an Integer with the variable/search Endpoint (which is not quoted in JSON) it works fine because the Integer is getting one quoted in the search-filter body.

Is there an option, where i can temporarely double quote the value TEST_KEY just for the searching? i dont find any expression for this.

I’m still not quite following. Can you share a screenshot of what you’re seeing in Operate?

I think you can alter your filter to look like this and it may work as needed here? Using string concatenation you can wrap the value in double quotes.

= { "name": "TEST_KEY", "value": "\"" + TEST_KEY + "\""}

I don’t have a copy of the Operate Connector, but if you click on the “JSON String” in the initial dialog box, I think it will tell you about the required format. I remember that “JSON String” is not simply a string representing JSON… I think it needs to be a fully escaped string (meaning all " need to be replaced with " )

@nathan.loding I also tried the concetanation but with every accepted version of using a Backslash as Expression, it will add two Backslashes:

The Key is looking like this in Operate:
image

The Kafka Consumer Connector is also saving the consumed Message in a rawValue with double quoted values. I tried to Extract the Key with this function:

substring before(substring after(rawValue, "TEST_KEY\":{\"value\":"), "},\"MOCK")

in th FEEL Playground it worked (Try out and learn DMN FEEL - FEEL Playground) but when im trying to use this Expression in Camunda, im getting an empty String.

In Modeler:

And in Operate:
image

I’m remain confused on what I’m seeing here, because the values are very different in each situation. If we remove the escapes from your FEEL Playground screenshot, it’s searching for "TEST_KEY":{"value"}, and your other screenshots do not have TEST_KEY as a context object but rather a string. Based on the screenshots shared, I would not expect extractedString’s expression to work.

Backslashes need to be escaped also, so seeing the Connector escaping them doesn’t surprise me. I am not sure there should be three backslashes total, though. I would have expected "value":"\\"ThisIsATestKey\\"".

Because the value is coming from Kafka with quotes, I would suggest doing your testing with quotes also. Going back to the first post and first screenshot, I would try starting the process with { "TEST_KEY": "\"ThisIsATestKey\"" }. Then, when you are using the value of TEST_KEY later in the filter parameters, it will already contain the quotes. Based on my limited testing, I believe that combination should work. (Either that, or go the opposite way and see if Kafka can produce the value without quotes. I don’t know Kafka well at all, so I am not sure if that’s possible.)

I posted a similar issue today.

In my case, I’m setting the process variable that I later want to filter on like:
"requestId": string(value.requestId)

The reason I need to use the string() method on this value is because it is a 19 digit numeric and if I store that in a process variable without converting it to a string, the value gets altered.

In Swagger, the values show up as "\"1234567890123456789\"" and while I can get the results in Swagger UI, I am unable to do the same using the variable search API in conjunction with REST or Operate Connectors.

My workaround has been to use the Process Instance Search, filtered on processId and sorted by startDate DESC, then use the processInstanceKey as a filter in Variable Search, then check to see if I’ve got the correct instance key or not.

I’ve tried a lot of different ways of specifying the filter but not found a solution.

1 Like

There’s a bug on Operate that makes searches way too complex.