2

I recently updated my bpmn-js libraries to version 0.26.6. However, now that I have done so, I have ran into an issue with my diagrams.

For some reason, when parsing the diagram to XML, the SequenceFlow objects seem to have an added property, like this:

<bpmn:sequenceFlow id="SequenceFlow_0itptjk" name="x===1" sourceRef="ExclusiveGateway_16fh3h3" targetRef="Task_10pxcz5" $type="bpmn:SequenceFlow">
    <bpmn:conditionExpression language="JavaScript" xsi:type="bpmn:tFormalExpression">x===1</bpmn:conditionExpression>
</bpmn:sequenceFlow>

The problem is that the $type="bpmn:SequenceFlow" is not valid XML, and it's not passing the validations.

{
  "name": "FlowElement",
  "isAbstract": true,
  "superClass": [
    "BaseElement"
  ],
  "properties": [
    {
      "name": "name",
      "isAttr": true,
      "type": "String"
    },
    {
      "name": "auditing",
      "type": "Auditing"
    },
    {
      "name": "monitoring",
      "type": "Monitoring"
    },
    {
      "name": "categoryValueRef",
      "type": "CategoryValue",
      "isMany": true,
      "isReference": true
    }
  ]
},{
  "name": "SequenceFlow",
  "superClass": [
    "FlowElement"
  ],
  "properties": [
    {
      "name": "isImmediate",
      "isAttr": true,
      "type": "Boolean"
    },
    {
      "name": "conditionExpression",
      "type": "Expression",
      "xml": {
        "serialize": "xsi:type"
      }
    },
    {
      "name": "sourceRef",
      "type": "FlowNode",
      "isAttr": true,
      "isReference": true
    },
    {
      "name": "targetRef",
      "type": "FlowNode",
      "isAttr": true,
      "isReference": true
    }
  ]
},{
  "name": "BaseElement",
  "isAbstract": true,
  "properties": [
    {
      "name": "id",
      "isAttr": true,
      "type": "String",
      "isId": true
    },
    {
      "name": "documentation",
      "type": "Documentation",
      "isMany": true
    },
    {
      "name": "extensionDefinitions",
      "type": "ExtensionDefinition",
      "isMany": true,
      "isReference": true
    },
    {
      "name": "extensionElements",
      "type": "ExtensionElements"
    }
  ]
}

As you can see, none of those have anything that indicates why the $type is being added.

Has anyone ran into this problem in the past?

--EDIT--

After doing some testing, it seems that the $type parameter is added when a conditional expression is added to the SequenceFlow. Otherwise, the property is not added, and the XML is valid.

--EDIT2--

These are the XML definitions I am using:

<bpmn:definitions id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

--EDIT3--

A bit more details after more troubleshooting. It seems that this error is not just affecting conditional flows - it is affecting ALL types. The error happens exactly after an update, which is executed in

UpdatePropertiesHandler.prototype.execute = function(context) ...

Inside that function, there is a call to

setProperties(businessObject, properties);

Inside that set, there's this

function setProperties(businessObject, properties) {
  forEach(properties, function(value, key) {
    businessObject.set(key, value);
  });
}

After that forEach, the businessObject suddenly has a $type inside its $attrs. It's as if instead of businessObject.set, it was doing businessObject.$attr.set.

Nacho321
  • 1,911
  • 7
  • 33
  • 55
  • Is the conditional expression being added by some code you have written? – Jankapunkt Feb 19 '18 at 21:29
  • The conditional is being added by the default camunda engine, using the 'element.updateProperties' action. One thing I've noticed is that when performing the update, the "oldProperties" contain an array called "$attrs" that contains the prototype. The "newProperties" contain the same array, but besides the prototype, it contains the "$type" that is causing the problem. – Nacho321 Feb 19 '18 at 21:32
  • camunda engine=bpmn-js? If so, isn't `element.updateProperties` called in your code somewhere? I am just asking because I had a similar issue solved in the past, where I extended the bpmn.io modeler in order to let me type in my condition expressions by using an html form. – Jankapunkt Feb 19 '18 at 21:37
  • The modeler I'm using is this one: https://raw.githubusercontent.com/bpmn-io/bower-bpmn-js/master/dist/bpmn-modeler.js The only reference to that .js file outside of it is when calling the toXML to perform a save to my DB. I'll update the question with the XML definitions I am using. – Nacho321 Feb 19 '18 at 21:41
  • Ok cool so I can try to replicate the issue. – Jankapunkt Feb 19 '18 at 21:52
  • For what it's worth, the files I updated where the bpmn-modeler.js, bpmn-viewer.js, and bpmn-navigated-viewer.js. – Nacho321 Feb 20 '18 at 02:11
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165484/discussion-between-jankapunkt-and-nacho321). – Jankapunkt Feb 20 '18 at 10:40

1 Answers1

1

I found the reason for this problem. It seems that the version of bpmn-js I was using wasn't fully compatible with the camunda-moddle version that the project relies on to parse the bpmn to xml. The solution was to revert bpmn-js a version at a time until I found one that was compatible and didn't have any unexpected properties being mishandled by the camunda-moddle.

Nacho321
  • 1,911
  • 7
  • 33
  • 55