Clearing labels results in errors during bpmnlint run

Hello everyone
After clearing a task’s label, the next bpmnlint run produces errors:

rule <fake-join> failed with error:  TypeError: Cannot read properties of null (reading '$instanceOf')
    at is$7 (lintRules.js:37:1)
    at lintRules.js:53:1
    at Array.some (<anonymous>)
    at isAny$4 (lintRules.js:52:1)
    at check (lintRules.js:118:1)
    at traverse.enter (test-rule.js:70:1)
    at traverse (traverse.js:13:1)
    at traverse.js:32:1
    at Array.forEach (<anonymous>)
    at traverse (traverse.js:23:1)

I’m not sure I got everything right but I think accessing null is the result of passing null to the lint rules. This null element here at this line is the result of having a ModdleElement like
{ $type: 'bpmndi:BPMNShape', label: null, ... }

I tried several things to reset my label name:

  • Using modeling.updateLabel() with undefined, null or ''
  • Using modeling.updateProperties('name', ...) with undefined, null or '' because it has a special handling for undefined: it deletes the property (see here) - a feature which is not offered by updateLabel() (see LabelUtil.js#L61)

Is there a special function to reset a label? Or do I have to call an additional function after updateProperties()? Do I somehow need to delete an element from the element registry?

Hi @epictecch ,

looks like a bug in bpmnlint to me. I can reproduce it, so there is nothing you are doing wrong. It is just broken:

Recording 2022-04-22 at 10.13.44

Please create a bug report in the bpmnLint repo so we can keep track of it.
As you already spent some time root causing it, would you be willing to contribute a Pull Request with a possible fix?


Hi @Martin

Thanks for your answer! I will create a bug report and refer to this discussion.
Yes, I’m willing to contribute a pull request but I need some help to get started. Without knowing the concepts of bpmnlint, my fix would just be to not traverse elements being null or undefined. Currently, I’m not sure whether this is the way to go.

And more general: Are there other components or whole projects assuming these properties not to be null? If so, I think the fix should be to delete the label property (delete businessObject['label']) instead of nulling it. This way, the labels behave the same way as properties being updated with modeling.updateProperties(). This fix would be required to be in bpmn-js.
Of course it still makes sense to harden the code in bpmnlint so it can deal with properties being null.


1 Like

This fix would be required to be in bpmn-js

You are right, this worked in previous versions of bpmn-js-lint (just checked with bpmn-js-bpmnlint@0.16.0), so this is a regression in bpmn-js and not the linting itself.

It was probably introduced with the changes in bpmn-js@9, specifically decoupling of the di. I’ll see if I can root cause what is broken there.

Thank you so much for bringing this up, I would have overlooked it otherwise

I created a ticket in bpmn-js with my findings and commit that broke it: `Label` property exists after clearing the name · Issue #1637 · bpmn-io/bpmn-js · GitHub

You can follow the progress there. As I already found the line that broke it, I can take care of the PR on this one :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.