camunda / camunda-modeler

An integrated modeling solution for BPMN, DMN and Forms based on bpmn.io.
https://camunda.com/products/modeler
MIT License
1.5k stars 481 forks source link

Non-Supported Template Properties Applied to Element #3971

Open philippfromme opened 1 year ago

philippfromme commented 1 year ago

Describe the bug

I can apply the following template to a bpmn:Task even though the zeebe:TaskDefinition extension element is only supported by a bpmn:ServiceTask. The meta data isn't taken into account.

{
  "$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
  "name": "Service Task",
  "id": "foo",
  "appliesTo": [
    "bpmn:Task"
  ],
  "properties": [
    {
      "type": "String",
      "value": "taskDefinitionType",
      "binding": {
        "type": "zeebe:taskDefinition",
        "property": "type"
      }
    },
    {
      "type": "String",
      "value": "retries",
      "binding": {
        "type": "zeebe:taskDefinition",
        "property": "retries"
      }
    }
  ]
}

https://github.com/camunda/camunda-modeler/assets/7633572/d3aad30b-b13f-4349-8e63-8bfa99125cb6

Steps to reproduce

  1. Create template for zeebe:TaskDefinition properties
  2. Apply template to bpmn:Task
  3. zeebe:TaskDefinition extension element is created

Expected behavior

Either template cannot be applied in the first place or only applicable properties are applied.

Environment

Additional context

https://github.com/bpmn-io/bpmn-js-element-templates/pull/29

barmac commented 1 year ago

We don't validate the element type also for other binding types. The only exception are bpmn:Message* bindings where we enforce BPMN compliance (no message binding on Service Task etc.).

At the moment, the JSON schema is not strict enough, so we rely on template developer for correctness. Perhaps it would make sense to enforce the correct types instead.