bpmn-io / element-templates-cli

Apply element templates on BPMN elements in your terminal.
MIT License
1 stars 0 forks source link

Property with zeebe:taskHeader binding not reflected in BPMN XML if exist condition for this property #1

Closed Oleksiivanov closed 5 months ago

Oleksiivanov commented 7 months ago

Describe the Bug

When using a conditional for resultExpression property with a zeebe:taskHeader binding in an element template, the expected resultExpression is not being added to the in the generated BPMN XML for specific conditions.

Steps to Reproduce

  1. Clone the repository from the test branch: https://github.com/camunda/connectors/tree/easy_post_e2e_tests

  2. go to https://github.com/camunda/connectors/blob/easy_post_e2e_tests/connectors-e2e-test/connectors-e2e-test-easy-post/src/test/java/io/camunda/connector/e2e/EasyPostTests.java and run tests with debug, putting debug mark after creating result.bpmn file , like here :

    Screenshot 2023-11-28 at 18 54 07
  3. find a patch with the generated result.bpmn file:

    Screenshot 2023-11-28 at 18 55 21
  4. open result.bpmn

  5. now you can see that resultExpression exist in the headers in the XML file :

    Screenshot 2023-11-28 at 18 21 12
  6. go to Easy-post-connector-template.json and add to resultExpression property condition :

    "condition": {
        "property": "operationType",
        "oneOf": [
          "createAddress",
          "createParcel",
          "createShipment",
          "buyShipment"
        ]
      },
    Screenshot 2023-11-28 at 18 57 20
  7. run tests with debug

  8. go to the newly generated result.bpmn file

  9. and you see that resultExpression not exist

    Screenshot 2023-11-28 at 18 58 57

Expected Behavior

I can use the condition for zeebe:taskHeaders binding in the connector template for testing; Condition not affect resultExpression and other header properties

Environment

Oleksiivanov commented 7 months ago

@barmac , please look at this and say if you need more info about this bug

barmac commented 7 months ago

Can you reproduce the problem in Desktop or Web Modeler?

If the bug exists in this hackdays project only, please provide a template with which I can reproduce it.

nikku commented 7 months ago

@Oleksiivanov Any chance to follow-up on https://github.com/bpmn-io/element-templates-cli/issues/1#issuecomment-1831557489? How can we reproduce the issue?

sbuettner commented 6 months ago

@nikku As @Oleksiivanov is not available this week I will try to provide a way to reproduce it. The Easy Post Connector is making use of conditions for different operations and refers to them to have dedicated result expressions per operation: Example:

{
      "label": "Result expression",
      "id": "resultExpressionGet",
      "description": "Expression to map the response into process variables. Details in the <a href=\"https://docs.camunda.io/docs/components/connectors/use-connectors/#result-expression\" target=\"_blank\">documentation</a>",
      "group": "output",
      "type": "String",
      "feel": "required",
      "value": "={trackerStatus: response.body.status}",
      "binding": {
        "type": "zeebe:taskHeader",
        "key": "resultExpression"
      },
      "condition": {
        "property": "operationType",
        "oneOf": [
          "retrieveTracker"
        ]
      }
    }

https://github.com/camunda/connectors/blob/0c3f4af938c3d52e9143a2ea6aa1ab48eeead636/connectors/easy-post/element-templates/easy-post-connector.json#L906

When applying a template the conditions are not considered and therefore lead to a BPMN file missing the right result expression. We thought that it might be related to the fact that these bindings are using the type zeebe:taskHeader.

nikku commented 6 months ago

@barmac Can we reproduce the issue given what Simon reported?

Oleksiivanov commented 6 months ago

@sbuettner, thank you for providing an example. @barmac, I'm back and available, so if you still need more information, please let me know.

barmac commented 6 months ago

I will check this and get back to you with the results.

barmac commented 6 months ago

I applied the template to the Service Task in this diagram:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1c27vni" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.16.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.0">
  <bpmn:process id="Process_0hqfcqr" isExecutable="true">
    <bpmn:task id="ServiceTask" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0hqfcqr">
      <bpmndi:BPMNShape id="Activity_11ibm9n_di" bpmnElement="ServiceTask">
        <dc:Bounds x="160" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

and it resulted in:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1c27vni" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0-nightly.20231218" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.0">
  <bpmn:process id="Process_0hqfcqr" isExecutable="true">
    <bpmn:serviceTask id="ServiceTask" zeebe:modelerTemplate="io.camunda.connectors.EasyPost.v1" zeebe:modelerTemplateVersion="3" zeebe:modelerTemplateIcon="data:image/svg+xml;utf8,%3Csvg xmlns=&#39;http://www.w3.org/2000/svg&#39; xmlns:xlink=&#39;http://www.w3.org/1999/xlink&#39; version=&#39;1.1&#39; width=&#39;18&#39; height=&#39;18&#39; viewBox=&#39;0 0 1000 1000&#39; xml:space=&#39;preserve&#39;%3E%3Cdesc%3ECreated with Fabric.js 3.5.0%3C/desc%3E%3Cdefs%3E%3C/defs%3E%3Crect x=&#39;0&#39; y=&#39;0&#39; width=&#39;18&#39; height=&#39;100%25&#39; fill=&#39;%23ffffff&#39;/%3E%3Cg transform=&#39;matrix(0.2007 0 0 -0.1895 500.0727 500.0583)&#39; id=&#39;344493&#39;%3E%3Cpath style=&#39;stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; is-custom-font: none; font-file-url: none; fill: rgb(17,90,241); fill-rule: nonzero; opacity: 1;&#39; vector-effect=&#39;non-scaling-stroke&#39; transform=&#39; translate(-2549.75, -2559.5281)&#39; d=&#39;M 2475 5110 c -22 -5 -59 -17 -81 -27 c -23 -10 -470 -265 -994 -568 c -682 -394 -966 -563 -999 -595 c -54 -52 -96 -131 -111 -209 c -14 -73 -14 -2229 0 -2302 c 14 -76 54 -152 108 -207 c 37 -37 257 -168 1023 -610 c 901 -519 982 -564 1050 -578 c 74 -15 130 -13 199 8 c 19 6 474 263 1010 572 c 1044 601 1047 603 1096 710 c 37 80 45 146 42 338 l -3 176 l -980 -565 c -539 -310 -1007 -578 -1040 -595 c -70 -36 -160 -47 -221 -28 c -21 7 -265 145 -541 308 l -503 296 l 0 229 l 0 229 l 33 -20 c 17 -11 244 -142 503 -291 c 517 -298 534 -306 639 -284 c 45 10 262 132 1085 610 l 1029 598 l 1 258 l 0 258 l -22 -12 c -13 -7 -473 -271 -1023 -587 c -550 -317 -1020 -582 -1045 -589 c -60 -19 -145 -11 -202 18 c -25 13 -260 150 -522 304 l -475 280 l -1 228 l 0 228 l 23 -12 c 12 -7 229 -131 482 -277 c 253 -146 480 -274 505 -285 c 52 -23 146 -28 200 -9 c 19 7 494 279 1055 605 l 1020 594 l 3 183 c 2 140 -1 197 -13 244 c -19 74 -68 158 -117 200 c -50 44 -1962 1146 -2015 1162 c -59 18 -150 24 -198 14 z&#39; stroke-linecap=&#39;round&#39;/%3E%3C/g%3E%3C/svg%3E">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="io.camunda:http-json:1" />
        <zeebe:ioMapping>
          <zeebe:input target="operationType" />
          <zeebe:input source="basic" target="authentication.type" />
          <zeebe:input target="authentication.username" />
          <zeebe:input source="SPEC_PASSWORD_EMPTY_PATTERN" target="authentication.password" />
          <zeebe:input source="20" target="connectionTimeoutInSeconds" />
        </zeebe:ioMapping>
        <zeebe:taskHeaders />
      </bpmn:extensionElements>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0hqfcqr">
      <bpmndi:BPMNShape id="Activity_1637c3y_di" bpmnElement="ServiceTask">
        <dc:Bounds x="160" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

There is no difference between whether I use this project or Desktop Modeler.

barmac commented 6 months ago

Let me know what XML you expect so that we can support you in building the template, unless there is a bug in the template mechanism.

sbuettner commented 6 months ago

@barmac Looks like the task headers are missing in your output XML. Please try to define a value for the result expression: https://github.com/camunda/connectors/blob/0c3f4af938c3d52e9143a2ea6aa1ab48eeead636/connectors/easy-post/element-templates/easy-post-connector.json#L906 and see whether the result gets applied correctly.

barmac commented 6 months ago

The headers are empty but it's the result of how the template is coded, and not the element-templates-cli. If you want to have a default value in your template you need to use the value field on the property:

    {
      "label": "Result expression",
      "id": "resultExpression",
      "description": "Expression to map the response into process variables. Details in the <a href=\"https://docs.camunda.io/docs/components/connectors/use-connectors/#result-expression\" target=\"_blank\">documentation</a>",
      "group": "output",
      "type": "String",
      "feel": "required",
      "value": "= \"my default value\"",
      "binding": {
        "type": "zeebe:taskHeader",
        "key": "resultExpression"
      },
      "condition": {
        "property": "operationType",
        "oneOf": [
          "verifyAddresById"
        ]
      }
    }
sbuettner commented 6 months ago

Sure but the issue and please @Oleksiivanov chime in please was that even if a value was provided it wasn’t successfully applied as the result expression was missing.

Oleksiivanov commented 6 months ago

It looks interesting. it is not reproducible for the rest template, but it is reproducible for easy-post template; I don't have a permission to push my branch with an example, so, will show it here :

When I add property with condition

  {
      "id" : "resultExpression",
      "label" : "Result expression",
      "description" : "Expression with condition nad prefilled value",
      "feel" : "required",
      "group" : "output",
      "value": "={addressId:response.body.id}",
      "binding" : {
        "key" : "resultExpression",
        "type" : "zeebe:taskHeader"
      },
      "type" : "Text",
      "condition": {
        "property": "httpMethod",
        "oneOf": ["patch", "post", "delete", "get"]
      }
    }

to rest template here https://github.com/bpmn-io/element-templates-cli/blob/main/test/fixtures/templates/rest-conditional.json , it works as expected. we can see headers;

However, when I add a new test using a real example of the easy-post connector, it does not work :

test :

  it('should apply an easy post template', async function() {

    // given
    const diagram = 'test/fixtures/diagrams/easy-post-conditional.bpmn';
    const template = 'test/fixtures/templates/easy-post-conditional.json';
    const element = 'easyPostCreateAddressTask';
    const expected = await fs.readFile('test/fixtures/diagrams/easy-post-conditional_expected.bpmn', 'utf8');

    // when
    const { stdout } = await exec({
      diagram,
      template,
      element
    });

    // then
    expect(stdout.trim()).to.eql(expected.trim());
  });

easy-post-conditional.bpmn :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" exporter="Zeebe BPMN Model" exporterVersion="8.3.4" id="definitions_4f02aaf6-9efc-4ceb-878c-f9eade0087cd" xmlns:modeler="http://camunda.org/schema/modeler/1.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.4" targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
  <process id="process_d7adcdc3-8fcd-4c1d-a05f-6c5a1c39ef74" isExecutable="true">
    <startEvent id="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5">
      <outgoing>sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8</outgoing>
    </startEvent>
    <serviceTask id="easyPostCreateAddressTask" name="easyPostCreateAddressTask">
      <incoming>sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8</incoming>
      <outgoing>sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba</outgoing>
    </serviceTask>
    <sequenceFlow id="sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8" sourceRef="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5" targetRef="easyPostCreateAddressTask"/>
    <endEvent id="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53">
      <incoming>sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba</incoming>
    </endEvent>
    <sequenceFlow id="sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba" sourceRef="easyPostCreateAddressTask" targetRef="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53"/>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_daf5348b-46f0-4f5e-ac85-5ae1e388b42f">
    <bpmndi:BPMNPlane bpmnElement="process_d7adcdc3-8fcd-4c1d-a05f-6c5a1c39ef74" id="BPMNPlane_fd72948b-d667-450f-b112-9d9171a602fc">
      <bpmndi:BPMNShape bpmnElement="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5" id="BPMNShape_8fb2fbc8-01cf-4026-b752-d2b2e650af55">
        <dc:Bounds height="36.0" width="36.0" x="100.0" y="100.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="easyPostCreateAddressTask" id="BPMNShape_5d9e7720-3995-401e-9e16-913fccb5188e">
        <dc:Bounds height="80.0" width="100.0" x="186.0" y="78.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8" id="BPMNEdge_6830f37a-3053-4ded-86bf-e8d538df377e">
        <di:waypoint x="136.0" y="118.0"/>
        <di:waypoint x="186.0" y="118.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape bpmnElement="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53" id="BPMNShape_2905ab49-0c1f-4467-871e-41a6ca0303de">
        <dc:Bounds height="36.0" width="36.0" x="336.0" y="100.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba" id="BPMNEdge_6987adeb-18f7-4cbf-bddb-78ff8b97947a">
        <di:waypoint x="286.0" y="118.0"/>
        <di:waypoint x="336.0" y="118.0"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

easy-post-conditional_expected.bpmn :

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="Definitions_1lg4ko0" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_1hi6bli" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_0bk0o5i</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="ServiceTask" zeebe:modelerTemplate="io.camunda.examples.ConditionalRestConnector">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="http" />
        <zeebe:ioMapping />
        <zeebe:taskHeaders>
          <zeebe:header key="method" value="get" />
          <zeebe:header key="resultExpression" value="={addressId:response.body.id}" />
        </zeebe:taskHeaders>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0bk0o5i</bpmn:incoming>
      <bpmn:outgoing>Flow_0o9uql4</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_0bk0o5i" sourceRef="StartEvent_1" targetRef="ServiceTask" />
    <bpmn:endEvent id="Event_1d1hxm0">
      <bpmn:incoming>Flow_0o9uql4</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0o9uql4" sourceRef="ServiceTask" targetRef="Event_1d1hxm0" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1hi6bli">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="159" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ServiceTask_di" bpmnElement="ServiceTask">
        <dc:Bounds x="270" y="137" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1d1hxm0_di" bpmnElement="Event_1d1hxm0">
        <dc:Bounds x="432" y="159" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_0bk0o5i_di" bpmnElement="Flow_0bk0o5i">
        <di:waypoint x="215" y="177" />
        <di:waypoint x="270" y="177" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0o9uql4_di" bpmnElement="Flow_0o9uql4">
        <di:waypoint x="370" y="177" />
        <di:waypoint x="432" y="177" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

and template : easy-post-conditional.json

So I will investigate this issue further, will try simplify template, explore other cases and after that provide an update

Oleksiivanov commented 6 months ago

@barmac , I find a reason for this issue.

Firstly expected result :

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="definitions_4f02aaf6-9efc-4ceb-878c-f9eade0087cd" targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL" exporter="Zeebe BPMN Model" exporterVersion="8.3.4" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.4">
  <process id="process_d7adcdc3-8fcd-4c1d-a05f-6c5a1c39ef74" isExecutable="true">
    <startEvent id="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5">
      <outgoing>sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8</outgoing>
    </startEvent>
    <serviceTask id="easyPostCreateAddressTask" name="easyPostCreateAddressTask" zeebe:modelerTemplate="io.camunda.connectors.EasyPost.v1" zeebe:modelerTemplateVersion="4" zeebe:modelerTemplateIcon="data:image/svg+xml;utf8,%3Csvg xmlns=&#39;http://www.w3.org/2000/svg&#39; xmlns:xlink=&#39;http://www.w3.org/1999/xlink&#39; version=&#39;1.1&#39; width=&#39;18&#39; height=&#39;18&#39; viewBox=&#39;0 0 1000 1000&#39; xml:space=&#39;preserve&#39;%3E%3Cdesc%3ECreated with Fabric.js 3.5.0%3C/desc%3E%3Cdefs%3E%3C/defs%3E%3Crect x=&#39;0&#39; y=&#39;0&#39; width=&#39;18&#39; height=&#39;100%25&#39; fill=&#39;%23ffffff&#39;/%3E%3Cg transform=&#39;matrix(0.2007 0 0 -0.1895 500.0727 500.0583)&#39; id=&#39;344493&#39;%3E%3Cpath style=&#39;stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; is-custom-font: none; font-file-url: none; fill: rgb(17,90,241); fill-rule: nonzero; opacity: 1;&#39; vector-effect=&#39;non-scaling-stroke&#39; transform=&#39; translate(-2549.75, -2559.5281)&#39; d=&#39;M 2475 5110 c -22 -5 -59 -17 -81 -27 c -23 -10 -470 -265 -994 -568 c -682 -394 -966 -563 -999 -595 c -54 -52 -96 -131 -111 -209 c -14 -73 -14 -2229 0 -2302 c 14 -76 54 -152 108 -207 c 37 -37 257 -168 1023 -610 c 901 -519 982 -564 1050 -578 c 74 -15 130 -13 199 8 c 19 6 474 263 1010 572 c 1044 601 1047 603 1096 710 c 37 80 45 146 42 338 l -3 176 l -980 -565 c -539 -310 -1007 -578 -1040 -595 c -70 -36 -160 -47 -221 -28 c -21 7 -265 145 -541 308 l -503 296 l 0 229 l 0 229 l 33 -20 c 17 -11 244 -142 503 -291 c 517 -298 534 -306 639 -284 c 45 10 262 132 1085 610 l 1029 598 l 1 258 l 0 258 l -22 -12 c -13 -7 -473 -271 -1023 -587 c -550 -317 -1020 -582 -1045 -589 c -60 -19 -145 -11 -202 18 c -25 13 -260 150 -522 304 l -475 280 l -1 228 l 0 228 l 23 -12 c 12 -7 229 -131 482 -277 c 253 -146 480 -274 505 -285 c 52 -23 146 -28 200 -9 c 19 7 494 279 1055 605 l 1020 594 l 3 183 c 2 140 -1 197 -13 244 c -19 74 -68 158 -117 200 c -50 44 -1962 1146 -2015 1162 c -59 18 -150 24 -198 14 z&#39; stroke-linecap=&#39;round&#39;/%3E%3C/g%3E%3C/svg%3E">
      <extensionElements>
        <zeebe:taskDefinition type="io.camunda:http-json:1" />
        <zeebe:ioMapping>
          <zeebe:input source="createAddress" target="operationType" />
        </zeebe:ioMapping>
        <zeebe:taskHeaders>
          <zeebe:header key="resultExpression" value="={addressId:response.body.id}" />
        </zeebe:taskHeaders>
      </extensionElements>
      <incoming>sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8</incoming>
      <outgoing>sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba</outgoing>
    </serviceTask>
    <sequenceFlow id="sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8" sourceRef="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5" targetRef="easyPostCreateAddressTask" />
    <endEvent id="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53">
      <incoming>sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba</incoming>
    </endEvent>
    <sequenceFlow id="sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba" sourceRef="easyPostCreateAddressTask" targetRef="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53" />
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_daf5348b-46f0-4f5e-ac85-5ae1e388b42f">
    <bpmndi:BPMNPlane id="BPMNPlane_fd72948b-d667-450f-b112-9d9171a602fc" bpmnElement="process_d7adcdc3-8fcd-4c1d-a05f-6c5a1c39ef74">
      <bpmndi:BPMNShape id="BPMNShape_8fb2fbc8-01cf-4026-b752-d2b2e650af55" bpmnElement="startEvent_f5088ad2-28fb-4665-9133-9c1499d748f5">
        <dc:Bounds x="100" y="100" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_5d9e7720-3995-401e-9e16-913fccb5188e" bpmnElement="easyPostCreateAddressTask">
        <dc:Bounds x="186" y="78" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_2905ab49-0c1f-4467-871e-41a6ca0303de" bpmnElement="endEvent_668b9d61-5368-47d3-a750-1c739bae0f53">
        <dc:Bounds x="336" y="100" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_6830f37a-3053-4ded-86bf-e8d538df377e" bpmnElement="sequenceFlow_0af33f9a-b9c1-447e-a583-1d18547d48d8">
        <di:waypoint x="136" y="118" />
        <di:waypoint x="186" y="118" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_6987adeb-18f7-4cbf-bddb-78ff8b97947a" bpmnElement="sequenceFlow_57c1d5e8-799f-496d-9f15-ac314a09b7ba">
        <di:waypoint x="286" y="118" />
        <di:waypoint x="336" y="118" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

rest template (added property resultExpression with condition) : rest-conditional.json

And an issue : Authentication type binding :

      "binding": {
        "type": "zeebe:input",
        "name": "authentication.type"
      }

and result expression binding :

 "binding" : {
        "key" : "resultExpression",
        "type" : "zeebe:taskHeader"
      },

So it looks like when we have the condition for the property with zeebe:taskHeader binding but property in the condition has "zeebe:input" binding it's doesn't work

barmac commented 6 months ago

I looked into your template and found the following:

  1. The property resultExpression requires authenticationType to have value basic in order to be active:
    {
      "id" : "resultExpression",
      "label" : "Result expression",
      "description" : "Expression with condition nad prefilled value",
      "feel" : "required",
      "group" : "output",
      "value": "={addressId:response.body.id}",
      "binding" : {
        "key" : "resultExpression",
        "type" : "zeebe:taskHeader"
      },
      "type" : "Text",
      "condition": {
        "property": "authenticationType",
        "oneOf": ["basic"]
      }
  1. Property authenticationType takes "" (empty string) as the default value ("value": ""):
    {
      "id": "authenticationType",
      "label": "Authentication Type",
      "description": "Specify the authentication type to use.",
      "type": "Dropdown",
      "value": "",
      "optional": true,
      "choices": [
        {
          "name": "None",
          "value": ""
        },
        {
          "name": "Basic",
          "value": "basic"
        },
        {
          "name": "Bearer",
          "value": "bearer"
        }
      ],
      "binding": {
        "type": "zeebe:input",
        "name": "authentication.type"
      }
    }

There is also a mismatch between XML and the template you shared in https://github.com/bpmn-io/element-templates-cli/issues/1#issuecomment-1864909982.

I will come up with a simple template so that we can verify it on a small, dedicated test case.

barmac commented 6 months ago

It looks like there is a problem with task headers handling. The result expression is not added even if I remove the condition in this template: https://github.com/bpmn-io/element-templates-cli/blob/1-task-header/test/fixtures/templates/task-header-with-condition.json

It works on the nightly Desktop Modeler though. I'd probably need to update the bpmn-js-element-templates distro in this project.

nikku commented 6 months ago

@barmac I moved this to ready as it looks like this may be an easy pick.

sbuettner commented 6 months ago

@nikku Would be great if we could prioritize this one as its blocking our e2e tests.

nikku commented 5 months ago

@sbuettner This is already in our next items bucket. To speed things up you may contribute a fix yourself.

sbuettner commented 5 months ago

@nikku Based on the comments it wasnt clear whether this only requires an update of dependencies or actual code changes in the CLI tool. We can certainly update dependencies and provide a PR if thats the case.

barmac commented 5 months ago

I will look into this this week.

barmac commented 5 months ago

@sbuettner @Oleksiivanov This is now published as v0.2.1

sbuettner commented 5 months ago

Thanks @barmac for the support. @Oleksiivanov will test the new release.

Oleksiivanov commented 5 months ago

Thanks @barmac for the support. @Oleksiivanov will test the new release.

I've tested it and now it works for me. Thank you again. And the unblocked PR with tests you can fin here: https://github.com/camunda/connectors/pull/1450