bpmn-io / element-templates-cli

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

Element Templates CLI Does Not Apply Properties as Expected #15

Closed Oleksiivanov closed 8 months ago

Oleksiivanov commented 9 months ago

Describe the Bug

The element-templates-cli does not apply specified properties from a JSON template to the BPMN model correctly, affecting the configuration of service tasks for DynamoDB operations.

Steps to Reproduce

  1. Open the element-templates-cli and configure it with the provided JSON template and bpmn files :

    • add add-item.bpmn to test/fixtures/diagrams
      add-item.bpmn click to expand!
    
    <?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_0hqfcqr1" isExecutable="true">
    <bpmn:task id="ServiceTask" />
    </bpmn:process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0hqfcqr1">
      <bpmndi:BPMNShape id="Activity_di" bpmnElement="ServiceTask">
        <dc:Bounds x="160" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
    </bpmn:definitions>
</details>

 - add `add-item_expected.bpmn` to `test/fixtures/diagrams`
 <details>
  <summary>add-item_expected.bpmn click to expand!</summary>

  ```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: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.16.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.0">
  <bpmn:process id="Process_0hqfcqr1" isExecutable="true">
    <bpmn:serviceTask id="ServiceTask" zeebe:modelerTemplate="05d1c06a-b65d-428c-8ca0-10c14b3fb0ee" zeebe:modelerTemplateVersion="3">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="io.camunda:aws-dynamodb:1" />
        <zeebe:ioMapping>
          <zeebe:input source="itemOperation" target="input.operationGroup" />
          <zeebe:input source="addItem" target="input.itemOperation" />
          <zeebe:input source="tableName" target="input.tableName" />
          <zeebe:input source="={&#34;id&#34;:&#34;value&#34;}" target="input.item" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
      <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0hqfcqr1">
          <bpmndi:BPMNShape id="Activity_1rrhra2_di" bpmnElement="ServiceTask">
              <dc:Bounds x="160" y="80" width="100" height="80" />
          </bpmndi:BPMNShape>
      </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Screenshot 2024-02-07 at 13 24 05
  1. run all tests : npm run build && npm run test

Observe that properties related to DynamoDB operations, such as tableName and item, are not applied as expected. :

Screenshot 2024-02-07 at 13 27 29

Expected Behavior

The BPMN model generated by the element-templates-cli should correctly include all specified properties from the JSON template. This includes inputs for tableName and item, allowing for proper interaction with DynamoDB within the process.

Environment


Depends on https://github.com/camunda/camunda-modeler/issues/4124

Oleksiivanov commented 9 months ago

Blocker for end-to-end tests of the DynamoDB connector. The template works correctly within the Modeler on INT and DEV environments, as well as with SM, yet it fails with the element-templates-cli. Despite efforts to identify the cause, no solution has been found so far. Attempts to diagnose the issue have yet to yield any findings. Notably, the template performs correctly if the condition "property": "input.itemOperation", "equals": "addItem" is omitted, however, this condition is essential and cannot be removed from the current implementation

Oleksiivanov commented 9 months ago

@barmac , FYI

barmac commented 9 months ago

Thanks for reporting. I'll check if I can reproduce it, and come back with results.

barmac commented 9 months ago

I was able to reproduce the issue, but don't know yet what causes the problem.

Oleksiivanov commented 9 months ago

I was able to reproduce the issue, but don't know yet what causes the problem.

Thank you for the update. Similarly, I can't find a reason, but this template works with the modeler, and it's already implemented in the connector. It's not urgent, so I will also try to find the reason for this bug when I have time. If there's an update, I'll inform you.

barmac commented 9 months ago

Hey, I tried this out in the current Desktop Modeler nightly build, and the result was:

  <bpmn:process id="Process_0mc4oc6" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
    <bpmn:serviceTask id="Activity_1tnooja" zeebe:modelerTemplate="05d1c06a-b65d-428c-8ca0-10c14b3fb0ee" zeebe:modelerTemplateVersion="3">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="io.camunda:aws-dynamodb:1" />
        <zeebe:ioMapping>
          <zeebe:input source="itemOperation" target="input.operationGroup" />
          <zeebe:input source="addItem" target="input.itemOperation" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
    </bpmn:serviceTask>
  </bpmn:process>

So it's what this tool generates.

barmac commented 9 months ago

And it's the same in Web Modeler:

  <bpmn:process id="Process_000j89q" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
    <bpmn:serviceTask id="Activity_1xauz6b" zeebe:modelerTemplate="7b629c5f-3890-415e-b450-351886a42090" zeebe:modelerTemplateVersion="1707386597105">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="io.camunda:aws-dynamodb:1" />
        <zeebe:ioMapping>
          <zeebe:input source="itemOperation" target="input.operationGroup" />
          <zeebe:input source="addItem" target="input.itemOperation" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
    </bpmn:serviceTask>
  </bpmn:process>
barmac commented 9 months ago

So I believe this is a problem with template or the templates backend, but not the CLI itself.

Oleksiivanov commented 9 months ago

interesting, rechecked on DEV web modeler:

Screenshot 2024-02-08 at 12 25 41

and in desktop 5.17.0 :

Screenshot 2024-02-08 at 12 27 04

So will try it on other desktop versions on with other environments (INT, PROD) and will add comment with results

barmac commented 9 months ago

5.19.0

  <bpmn:process id="Process_1pi1tsj" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
    <bpmn:serviceTask id="Activity_03hp3ck" zeebe:modelerTemplate="05d1c06a-b65d-428c-8ca0-10c14b3fb0ee" zeebe:modelerTemplateVersion="3">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="io.camunda:aws-dynamodb:1" />
        <zeebe:ioMapping>
          <zeebe:input source="itemOperation" target="input.operationGroup" />
          <zeebe:input source="addItem" target="input.itemOperation" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
    </bpmn:serviceTask>
  </bpmn:process>

but on 5.17.0 I can reproduce what you pasted.

barmac commented 9 months ago

So this has changed in 5.18.0, and before was as in your expected diagram.

Oleksiivanov commented 9 months ago

added question about this in the ask-modeler chat

barmac commented 9 months ago

Between the versions 5.17.0 and 5.18.0, we updated the templates project:

-    "bpmn-js-element-templates": "^1.7.0",
+    "bpmn-js-element-templates": "^1.8.0",
barmac commented 9 months ago

Only a single feature was shipped, and it didn't change the production code apart from a comment: https://github.com/bpmn-io/bpmn-js-element-templates/pull/30/files#diff-f8200a0ea8c31c5996490cbd7c2337350b21eea60f66122f98f28dcd37e5838d

barmac commented 9 months ago

❯ git diff v1.7.0 v1.8.0 -- src diff --git a/src/cloud-element-templates/util/propertyUtil.js b/src/cloud-element-templates/util/propertyUtil.js index 267c087..985a7f8 100644 --- a/src/cloud-element-templates/util/propertyUtil.js +++ b/src/cloud-element-templates/util/propertyUtil.js @@ -772,7 +772,7 @@ export function unsetProperty(commandStack, element, property) { }); }

barmac commented 9 months ago

Actually, in v5.18.0 we upgraded camunda-bpmn-js from v3.8.0 to v3.10.2, and it contained an upgrade of bpmn-js-element-templates from v1.7.0 to v1.9.2.

barmac commented 9 months ago

This is the diff between these versions: https://github.com/bpmn-io/bpmn-js-element-templates/compare/v1.7.0...v1.9.2

barmac commented 9 months ago

I just noticed that in 5.18.0 the XML looks as expected when I create element from template via triple dot (create/append anything), but is wrong when template is applied to an existing element.

barmac commented 9 months ago

So this is a bug for sure. I will create an issue in the Modeler repo.

barmac commented 9 months ago

The Modeler issue: https://github.com/camunda/camunda-modeler/issues/4124

barmac commented 9 months ago

I am moving this to the backlog until the core issue is fixed. We will then add your template to the test suite.

barmac commented 8 months ago

This is fixed in https://github.com/bpmn-io/element-templates-cli/pull/17