camunda / dmn-scala

DMN engine written in Scala
Apache License 2.0
34 stars 15 forks source link

Decision requirements id should not be null #224

Open koevskinikola opened 1 year ago

koevskinikola commented 1 year ago

Describe the bug Parsing a DMN resource where the definitions#id attribute is not present produces a ParsedDmnScalaDrg where the decisionRequirementsId is null.

The resulting ouput causes a NullPointerException in Zeebe, as reported in https://github.com/camunda/zeebe/issues/13847.

To Reproduce Steps to reproduce the behavior:

  1. Parse the following DMN resource:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" name="Force Users" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="4.11.0">
    <decision id="jedi_or_sith" name="Jedi or Sith">
    <decisionTable id="DecisionTable_14n3bxx">
      <input id="Input_1" label="Lightsaber color" biodi:width="192">
        <inputExpression id="InputExpression_1" typeRef="string">
          <text>lightsaberColor</text>
        </inputExpression>
      </input>
      <output id="Output_1" label="Jedi or Sith" name="jedi_or_sith" typeRef="string" biodi:width="192">
        <outputValues id="UnaryTests_0hj346a">
          <text>"Jedi","Sith"</text>
        </outputValues>
      </output>
      <rule id="DecisionRule_0zumznl">
        <inputEntry id="UnaryTests_0leuxqi">
          <text>"blue"</text>
        </inputEntry>
        <outputEntry id="LiteralExpression_0c9vpz8">
          <text>"Jedi"</text>
        </outputEntry>
      </rule>
      <rule id="DecisionRule_1utwb1e">
        <inputEntry id="UnaryTests_1v3sd4m">
          <text>"green"</text>
        </inputEntry>
        <outputEntry id="LiteralExpression_0tgh8k1">
          <text>"Jedi"</text>
        </outputEntry>
      </rule>
      <rule id="DecisionRule_1bwgcym">
        <inputEntry id="UnaryTests_0n1ewm3">
          <text>"red"</text>
        </inputEntry>
        <outputEntry id="LiteralExpression_19xnlkw">
          <text>"Sith"</text>
        </outputEntry>
      </rule>
    </decisionTable>
    </decision>
    <dmndi:DMNDI>
    <dmndi:DMNDiagram>
      <dmndi:DMNShape dmnElementRef="jedi_or_sith">
        <dc:Bounds height="80" width="180" x="160" y="100" />
      </dmndi:DMNShape>
    </dmndi:DMNDiagram>
    </dmndi:DMNDI>
    </definitions>
  2. The diagram will be parsed successfully.

Expected behavior When parsing a DMN resource where the definitions#id attribute is not present, the validation fails.

Environment

koevskinikola commented 1 year ago

@camunda/zeebe-process-automation triage: