Giter VIP home page Giter VIP logo

bpmnlint-plugin-camunda-compat's Introduction

bpmnlint-plugin-camunda-compat

CI

A bpmnlint plug-in that checks whether a given BPMN process can be executed with Camunda.

Usage

Add configuration corresponding to your execution platform and version to your .bpmnlintrc configuration:

{
  "extends": [
    "bpmnlint:recommended",
    "plugin:camunda-compat/camunda-cloud-8-0"
  ],
  "rules": {
    "camunda-compat/timer": "off"
  }
}

Use @camunda/linting to configure the linter dynamically based on the execution platform and version.

Resources

Related

License

MIT

bpmnlint-plugin-camunda-compat's People

Contributors

barmac avatar marstamm avatar maxtru avatar nikku avatar oleksiivanov avatar philippfromme avatar romansmirnov avatar smbea avatar

Watchers

 avatar  avatar  avatar  avatar

bpmnlint-plugin-camunda-compat's Issues

Add Rule for Sequence Flow Conditions

There is an existing rule (inclusive-gateway) that checks sequence flow conditions. However, this rule only checks inclusive gateways.

According to the implementation of Zeebe the rules are:

Sequence Flow

  • must have condition of be default sequence flow

Exclusive Gateway

Inclusive Gateway


Related to camunda/camunda-modeler#3157

Lint rules for expressions

Lint rules for expressions:

Error Message Version Link Comments
Expected path expression but not found. 1.0 ZeebeExpressionValidator
Expected path expression '%s' but doesn't match the pattern '%s'. 1.0 ZeebeExpressionValidator
Expected path expression '%s' but is one of the reserved words (%s). 1.0 ZeebeExpressionValidator
Expected expression but found static value '%s'. An expression must start with '=' (e.g. '=%s'). 1.0 ZeebeExpressionValidator
Expected static value to %s, but found '%s'. 1.0 ZeebeExpressionValidator

Child of #7

`feel` Rule Reports False Positives

The feel rule matches any property that starts with = regardless of whether this property can be a FEEL expression.

<bpmn:serviceTask name="==5" />

will lead to a report that name is not a valid feel expression.

A possible solution could be adding metadata to the camunda-bpmn-moddle extension.

Example:

{
  "name": "InputOutputParameter",
  "properties": [
    {
      "name": "name",
      "isAttr": true,
      "type": "String"
    },
    {
      "name": "value",
      "isBody": true,
      "type": "String",
      "meta": {
        "feel": true
      }
    },
    {
      "name": "definition",
      "type": "InputOutputParameterDefinition"
    }
  ]
},

We'll have to investigate whether this works for all FEEL properties. Alternatively, we could have a list of properties that are supposed to be linted.

Lint `zeebe:TaskSchedule` Extension Elements

zeebe:TaskSchedule extension elements supported by Camunda 8.2 will be validated by the engine. Both dueDate and followUpDate will be validated to be either valid FEEL expressions or valid ISO 8601 DateTime strings. zeebe:TaskSchedule extension elements are only allowed by Camunda 8.2 and newer.

<userTask id="UserTask_1">
    <extensionElements>
        <zeebe:taskSchedule dueDate="2023-04-20T04:20:00Z" followUpDate="=followUpDate" />
    </extensionElements>
</userTask>

Requires camunda/zeebe-bpmn-moddle#45
Related to camunda/camunda-modeler#3484

Detect Loops

The rule should detect the following modeling patterns

In order to prevent hard-to-debug runtime errors Zeebe will introduce loop detection (cf. camunda/zeebe#13025). The linter should be able to detect loops so they can be fixed before deployment.

How does the rule improve the BPMN diagram?

Loops are detected and can be fixed.

Rule Details

  • Name: no-loop
  • Default notification level: error

README is wrong for version 0.7

As of version 0.7, there is no recommended config exported anymore. So instead of plugin:camunda-compat/recommended you would have to use plugin:camunda-compat/camunda-cloud-8-0 or something similar.

It would also be great to have a migration guide how we can achieve a behavior similar to the previous recommended settings with version 0.7

Add validation rules for link events

Camunda 8.2 supports link events. We should introduce lint rule(s) that support the user in using the link event correctly.

  • require the name property to be set on both catching and throwing link events
  • validate that there isn't more than one catching link event with the same name
  • validate that catching and throwing events are children of the same process (Link
    Event uses are limited to a single Process level (i.e., they cannot link a
    parent Process with a Sub-Process)
    )
    Zeebe doesn't validate this either

Lint Rules for Required Extension Elements

Rules for mandatory presence of extension elements:

Element Error Message Version Link Comments
โœ… Message Must have exactly one zeebe:subscription extension element 1.0 MessageValidator if referenced by bpmn:SubProcess with triggeredByEvent="true", bpmn:IntermediateCatchEvent or bpmn:ReveiceTask
โœ… Business Rule Task Must have exactly one 'zeebe:TaskDefinition' extension element 1.1 ZeebeDesignTimeValidators until 1.3
โœ… Business Rule Task Must have either one 'zeebe:calledDecision' or one 'zeebe:taskDefinition' extension element 1.3 BusinessRuleTaskValidation since 1.3
โœ… Call Activity Must have exactly one 'zeebe:CalledElement' extension element 1.0 ZeebeDesignTimeValidators
โœ… Script Task Must have exactly one 'zeebe:TaskDefinition' extension element 1.1 ZeebeDesignTimeValidators
โœ… Send Task Must have exactly one 'zeebe:TaskDefinition' extension element 1.1 ZeebeDesignTimeValidators
โœ… Service Task Must have exactly one 'zeebe:TaskDefinition' extension element 1.0 ZeebeDesignTimeValidators
โœ… Multi-Instance Loop Characteristics Must have exactly one 'zeebe:loopCharacteristics' extension element 1.0 ZeebeDesignTimeValidators
โœ… Intermediate Throw Event Must have exactly one 'zeebe:TaskDefinition' extension element 1.2 MessageThrowEventValidator if bpmn:MessageEventDefinition

Child of #7

Lint rules for element properties

Rules for mandatory element attributes and attribute validation:

Attributes

Element Error Message Version Link Comments
Subscription 1.0 ZeebeRuntimeValidators zeebe:correlationKey must exist and be valid expression
Message Name must be present and not empty 1.0 MessageValidator if referenced by bpmn:SubProcess with triggeredByEvent="true", bpmn:IntermediateCatchEvent, bpmn:ReveiceTask or single bpmn:StartEvent
Subscription Attribute 'correlationKey' must be present and not empty 1.0 ZeebeDesignTimeValidators e.g. bpmn:ReceiveTask referencing a bpmn:Message with a zeebe:Subscription extension element
Receive Taks Must reference a message 1.0 ReceiveTaskValidator
User Task User task form text content has to be present and not empty 1.0 ZeebeUserTaskFormValidator
Called Decision Attribute 'decisionId' must be present and not empty 1.3 ZeebeDesignTimeValidators
Called Decicion Attribute 'resultVariable' must be present and not empty 1.3 ZeebeDesignTimeValidators
Form Definition Attribute 'formKey' must be present and not empty 1.0 ZeebeDesignTimeValidators
Called Element Attribute 'processId' must be present and not empty 1.0 ZeebeDesignTimeValidators
Loop Characteristics Attribute 'inputCollection' must be present and not empty 1.0 ZeebeLoopCharacteristicsValidator
Loop Characteristics Attribute 'outputElement' must be present if the attribute 'outputCollection' is set 1.0 ZeebeLoopCharacteristicsValidator
Loop Characteristics Attribute 'outputCollection' must be present if the attribute 'outputElement' is set 1.0 ZeebeLoopCharacteristicsValidator
Task Deifinition Attribute 'type' must be present and not empty 1.0 ZeebeDesignTimeValidators
Task Deifinition Attribute 'retries' must be present and not empty 1.0 ZeebeDesignTimeValidators
Task Header Attribute 'key' contains '%s', but header keys starting with '%s' are reserved for internal use. 1.3 ZeebeTaskHeadersValidator
Input 1.0 ZeebeRuntimeValidators zeebe:source must exist and be valid expression, zeebe:target must be valid path expression
Output 1.0 ZeebeRuntimeValidators zeebe:source must exist and be valid expression, zeebe:target must be valid path expression
Message 1.0 ZeebeRuntimeValidators bpmn:name must be valid if is expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/message-events/message-events/#messages)
Message Expected constant expression but found '%s', which could not be evaluated without context: %s 1.0 ProcessMessageStartEventMessageNameValidator if message referenced by bpmn:StartEvent
Message Expected constant expression of type String for message name '%s', but was %s 1.0 ProcessMessageStartEventMessageNameValidator if message referenced by bpmn:StartEvent
Loop Characteristics 1.0 ZeebeRuntimeValidators zeebe:inputCollection must exist and be valid expression, zeebe:outputElement must be valid if is expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/multi-instance/#defining-the-collection-to-iterate-over )
Condition Expression 1.0 ZeebeRuntimeValidators bpmn:conditionExpression must exist and be valid expression
Task Definition 1.0 ZeebeRuntimeValidators zeebe:type must be valid if expression, zeebe:retries must be valid if expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/service-tasks/service-tasks/#task-definition)
Called Element 1.0 ZeebeRuntimeValidators zeebe:processId must be valid if expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/call-activities/call-activities/#defining-the-called-process)
Timer Event Definition 1.0 ZeebeRuntimeValidators zeebe:timeCycle must be valid if expression, zeebe:timeDate must be valid if expression, zeebe:timeDuration must be valid if expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/timer-events/timer-events/#timers)
Timer Event Definition Repetition spec must start with R 1.0 RepeatingInterval must be valid ISO 8601 repeating intervals format (cf. https://docs.camunda.io/docs/components/modeler/bpmn/timer-events/timer-events/#time-cycle)
Timer Event Definition Invalid duration format '%s' for expression '%s' 1.0 ExpressionProcessor
Timer Event Definition Invalid date-time format '%s' for expression '%s' 1.0 ExpressionProcessor
Assignment Definition 1.3 ZeebeRuntimeValidators zeebe:assignmentDefinition must be valid if expression (cf. https://docs.camunda.io/docs/components/modeler/bpmn/user-tasks/user-tasks/#assignments)
Assignment Definition Expected static value to be a list of comma-separated values, e.g. 'a,b,c', but found '1,,' 1.3 ZeebeRuntimeValidators zeebe:assignmentDefinition must be valid if expression or list of comma-separated values
Called Decision 1.3 ZeebeRuntimeValidators zeebe:decisionId must exist and be valid expression
Multi-Instance Loop Characteristics 1.3 ZeebeRuntimeValidators zeebe:completionCondition must be valid if expression
Timer Event Definition Must be exactly one type of timer: timeDuration, timeDate or timeCycle 1.0 TimerEventDefinitionValidator
Sequence Flow Must have a condition or be default flow 1.0 SequenceFlowValidator if source is bpmn:ExclusiveGateway with more than 1 outgoing
Error Event Definition ErrorCode must be present and not empty 1.0 ErrorEventDefinitionValidator

Child of #7

`secrets` Rule Should Report Warning Instead of Error

secrets.FOO produces a lint error stating that the secret expression is not valid. In fact, this format is currently supported but will be deprecated in the future. Therefore the lint error should be a warning instead. The message should indicate the future deprecation and the new format ({{secrets.FOO}}).


Follow-up to #119

Disallow Condition If Sequence Flow Is Not Exclusive or Inclusive Gateway

The rule should detect the following modeling patterns

Incorrect: Camunda 8.1 will reject this:
converted-c8-conditional-flow.bpmn.txt

'converted-c8-conditional-flow.bpmn': - Element: DoSomethingTask
    - ERROR: Conditional sequence flows are only supported at exclusive or inclusive gateway

Correct: Camunda 8.1 will accept this:
converted-c8-inclusive-gateway.bpmn.txt

In addition, we consider modeling implicit gateways a bad practice, so even if zeebe will support conditional flows, this rule would still apply as warning or info.

How does the rule improve the BPMN diagram?

This rule will prevent users from creating undeployable diagrams.

Rule Details

  • Name: no-conditional-flows
  • Default notification level: error

What alternatives did you consider?

Validate linked forms in Web Modeler

What should we do?

When a user links a form (via formId) to a user task or start event, no lint error should be thrown when checking against a Zeebe version lower than 8.4 in Web Modeler.

Why should we do it?

For Web Modeler, we'll implement a mechanism where linked forms will automatically be converted to embedded forms when deploying to a cluster version lower than 8.4 (see camunda/web-modeler#6603 and camunda/web-modeler#6723). Displaying a lint error to the user in this case would be confusing as it could create the impression that deploying a BPMN diagram with linked forms to Zeebe < 8.4 would not work.

In Desktop Modeler, the lint rule for checking linked forms (implemented in #144) should still throw an error though as no automatic conversion mechanism exists.

This means the following combinations should throw lint errors (:x:) or pass the linter (โœ…) in Web Modeler:

Zeebe >= 8.3 Zeebe < 8.3
Linked Start Form โœ… โŒ
Embedded Start Form โœ… โŒ
Linked User Task Form โœ… โœ…
Embedded User Task Form โœ… โœ…

Acceptance Criteria

Definition of Ready - Checklist

  • the issue has a meaningful title, description and testable acceptance criteria
  • edge cases and limitations are clear
  • unclear requirements have been broken down into separate issues (always make progress)

Include no-bpmndi rule

Problem

We already had multiple cases where deployments to Camunda failed or went to unexpected results, because of missing bpmndi info.

See:

Solution proposal

The no-bpmndi rule detects such cases: https://github.com/bpmn-io/bpmnlint/blob/master/rules/no-bpmndi.js. We could easily include it in our standard camunda-compat ruleset. It also fits well, since it ensures, that the diagram can successfully be deployed to Camunda.

False error on lint <bpmn:serviceTask> and <bpmn:callActivity>

Hi! I try to use youre plugin with bpmnlint, for validate my bpmn xml files.
I run "npm install [email protected]"
I am exporting xml from camunda modeler desktop, writing for 8.0.0.
My .bpmnlintrc file:

{
  "extends": [
    "bpmnlint:recommended",
    "plugin:camunda-compat/camunda-cloud-8-0"
  ],
  "rules": {
    "label-required": "off"
  }
}

After i run: bpmnlint file_name.bpmn, i get:

Activity_0xo3d6b error Element of type bpmn:ServiceTask must have one extension element of type zeebe:TaskDefinition calculate action [product action calculator]
Activity_0vdvlk5 error Element of type bpmn:ServiceTask must have one extension element of type zeebe:TaskDefinition calculate action [product action calculator]
Activity_0oq172q error Element of type bpmn:ServiceTask must have one extension element of type zeebe:TaskDefinition calculate action [product action calculator]
Activity_1w1cci3 error Element of type bpmn:CallActivity must have one extension element of type zeebe:CalledElement fulfill product action

But all types include in file, for example:
zeebe:calledElement:

<bpmn:callActivity id="Activity_1w1cci3" name="fulfill product action">
      <bpmn:extensionElements>
         <zeebe:calledElement processId="ProductFulfillment" propagateAllChildVariables="false" />
         <zeebe:ioMapping>
            <zeebe:input source="=productAction" target="productAction" />
         </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0c05f1n</bpmn:incoming>
      <bpmn:outgoing>Flow_0krmk5r</bpmn:outgoing>
</bpmn:callActivity>

zeebe:TaskDefinition:

<bpmn:serviceTask id="Activity_0xo3d6b" name="calculate action [product action calculator]">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="http" retries="3" />
        <zeebe:ioMapping>
            <zeebe:input source="=productEvent.productId" target="body.product.id" />
            <zeebe:output source="=body" target="productAction" />
        </zeebe:ioMapping>
        <zeebe:taskHeaders>
            <zeebe:header key="method" value="POST" />
            <zeebe:header key="url" value="{{PUBLIC_URL}}/productActionCalculator/calculateActionBySubscriptionTerminatedEvent" />
        </zeebe:taskHeaders>
</bpmn:extensionElements>

What i do wrong? I run on node 18, macOs 12.1 (Monterey)

Lint rules for unique properties

Element Error Message Version Link Comments
root Multiple error event definitions with the same errorCode '%s' are not allowed. 1.0 ModelUtil
message Multiple message event definitions with the same name '%s' are not allowed. 1.0 ModelUtil
sub process Multiple message event definitions with the same name '%s' are not allowed. 1.0 SubProcessValidator if bpmn:SubProcess with triggeredByEvent="true"
sub process Multiple error event definitions with the same errorCode '%s' are not allowed. 1.0 SubProcessValidator if bpmn:SubProcess with triggeredByEvent="true"
Event-Based Gateway Multiple message event definitions with the same name 'msg' are not allowed. 1.0 EventBasedGatewayValidator

Child of #7

Lint rules related to child elements

Rules related to mandatory child elements:

Element Error Message Version Link Comments
- Must contain at least one executable process 1.0 DefinitionsValidator
- Must have at least one start event 1.0 ProcessValidator
- Multiple none start events are not allowed 1.0 ProcessValidator
Process Multiple none start events are not allowed 1.0 ProcessValidator
Sub Process Must have exactly one start event 1.0 SubProcessValidator
Message Event Must reference a message 1.0 MessageEventDefinitionValidator if not throwing
error event Must reference an error 1.0 ErrorEventDefinitionValidator
start event Start event can't have more than one type 1.0 StartEventValidator
Event-Based Gateway Event-based gateway must have at least 2 outgoing sequence flows. 1.0 EventBasedGatewayValidator
Event-Based Gateway Event-based gateway must not have an outgoing sequence flow to other elements than message/timer intermediate catch events. 1.0 EventBasedGatewayValidator
Event-Based Gateway Target elements of an event gateway must not have any additional incoming sequence flows other than that from the event gateway. 1.0 EventBasedGatewayValidator

Child of #7

`Form must be defined` should be a warning

Problem

Currently, a missing form is marked as an error. However, one can still deploy a diagram to Camunda 8.4.1 (this one I checked) even if a form is not defined. Moreover, there is a use case for such underimplemented form as reported by @NPDeehan in https://camunda.slack.com/archives/C0693F1NFK5/p1706613498853189.

Expected behavior

The linting rule should report a warning as we still want to encourage the users to define forms, but don't want to overreact as deployment can still succeed if form is missing.

Disallow dummy/static conditions on outgoing sequence flows from OR/XOR gateways

Originally reported by @till-stadtler in bpmn-io/bpmnlint#120.

The rule should detect the following modeling patterns

Conditions on outgoing sequence flows should always contain at least one process variable. If these conditions do not contain any process variable (dummy condition), they always evaluate to the same value.

If this value is false, the outgoing sequence flow will never be taken. This should be highlighted.

If this value is true:

  • in XOR gateways: this sequence flow will always be taken, and an incident might be thrown if another outgoing sequence flow evaluates to true as well
  • in OR gateways: in this case, the OR gateway should be replaced with the combination of a parallel gateway and another XOR/OR gateway to improve readability

If the dummy condition evaluates to false, this rule highlights that a certain path can never be taken.
If the dummy condition evaluates to true, this rule helps to avoid an incident arising or suggests a helpful refactoring.

Without the rule, BPMN models will continue to include dummy conditions on sequence flows behind OR/XOR gateways.

How does the rule improve the BPMN diagram?

Without the rule, BPMN models will continue to include dummy conditions on sequence flows behind OR/XOR gateways.

Rule Details

  • Name: no-dummy-conditions / static-expression
  • Default notification level: warn

`no-loop` Rule Detects False Positives

The no-loop rule aims to detect potential loops. These can also include call activities. If a call activity calls its parent process, it can cause an endless loop. The no-loop rule mirrors the behavior of Zeebe and only reports an error if the called process ID is the same as the parent process ID. However, it also reports an error if the call activity is part of a potential loop regardless of the process it calls. This process deploys without errors:

image

Reported through Slack: https://camunda.slack.com/archives/C0693F1NFK5/p1707223390238339

Related to camunda/zeebe#13056

Validate start forms in Camunda 8.3

The rule should detect the following modeling patterns

  • Validate that start forms are only supported in Camunda 8.3

As a result this example diagram should yield a human readable error:

A form on a is only supported by Camunda 8.3 or newer

How does the rule improve the BPMN diagram?

Ensure users can discover if start forms are supported.

Rule Details

  • Name: start-form
  • Default notification level: error

What alternatives did you consider?

None.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.