Skip to content

Commit

Permalink
fix(no-bpmndi): prevent crash when bpmndi:BPMNDiagram is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth authored and barmac committed Dec 16, 2024
1 parent 566bec8 commit 2375448
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rules/no-bpmndi.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function getAllBpmnElements(rootElements) {
*/
function getAllDiBpmnReferences(definitionsNode) {
return flatten(
definitionsNode.diagrams.map((diagram) => {
definitionsNode.get('diagrams').map((diagram) => {

const diElements = diagram.plane.planeElement || [];

Expand Down
9 changes: 8 additions & 1 deletion test/rules/no-bpmndi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ RuleTester.verify('no-bpmndi', rule, {
id: 'danglingMessageFlow',
message: 'Element is missing bpmndi'
}
}
},
{
moddleElement: readModdle(__dirname + '/no-bpmndi/invalid-no-bpmn-diagram.bpmn'),
report: {
id: 'StartEvent_1',
message: 'Element is missing bpmndi'
}
},
]
});
6 changes: 6 additions & 0 deletions test/rules/no-bpmndi/invalid-no-bpmn-diagram.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?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" id="Definitions_1mnmazt" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.3.0">
<bpmn:process id="Process_0y636xa" isExecutable="true">
<bpmn:startEvent id="StartEvent_1"></bpmn:startEvent>
</bpmn:process>
</bpmn:definitions>

0 comments on commit 2375448

Please sign in to comment.