Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rules for ad-hoc subprocess completion configuration #196

Merged
merged 3 commits into from
Mar 7, 2025

Conversation

maff
Copy link
Member

@maff maff commented Mar 6, 2025

The completionCondition expression and cancelRemainingInstances attribute will only be supported in Camunda 8.8+. This PR adds support to raise an error if one of these properties is set on a lower version.

Proposed Changes

  • If the cancelRemainingInstances attribute is set to true: raise an error if the version is < 8.8
  • If an <bpmn:completionCondition /> element exists: raise an error if the version is < 8.8

An example process XML containing both properties:

  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:adHocSubProcess id="Activity_186wn7x" cancelRemainingInstances="false">
      <bpmn:task id="Activity_06d3rvb" name="A" />
      <bpmn:task id="Activity_1bkr1i6" name="B" />
      <bpmn:completionCondition xsi:type="bpmn:tFormalExpression">=myCondition</bpmn:completionCondition>
    </bpmn:adHocSubProcess>
  </bpmn:process>

Relates to camunda/camunda-modeler#4850.

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Mar 6, 2025
…ainingInstances only supported from camunda 8.8
@maff maff force-pushed the feature/4850-add-ad-hoc-completion-condition-support branch from 4811713 to ff4e5e8 Compare March 6, 2025 16:13
@maff maff changed the title feat: add linting for ad-hoc subprocess completion configuration feat: add rules for ad-hoc subprocess completion configuration Mar 6, 2025
@maff maff requested a review from barmac March 6, 2025 16:15
@maff maff marked this pull request as ready for review March 6, 2025 16:15
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Mar 6, 2025
@barmac
Copy link
Contributor

barmac commented Mar 7, 2025

Thanks for the contribution. So if I understand it correctly, in 8.7 we add ad-hoc subprocess support, but the completion condition and "cancel remaining instances" are not available, right?

Copy link
Contributor

@barmac barmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the comments for potential improvement. Then, we can merge the PR. Great quality of the contribution 🚀

data: {
node,
parentNode: null
if (!greaterOrEqual(version, COMPLETION_ATTRIBUTES_SUPPORT_VERSION)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the hasProperties or hasProperty helper for the checks. This decouples the error message from the rule, and also attaches the metadata (error type) consistently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

errors = hasProperties(subscription, {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one with allowedVersion:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it to use the hasProperties check - as far as I could see the helper still needs the version check around the call as the version passed as argument is only used to generate the error message. Still needed to keep that check on the cancelRemainingInstances property being defined to achieve the desired check.

];

RuleTester.verify('called-element', rule, {
RuleTester.verify('ad-hoc-sub-process', rule, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scout rule - I like it :)

@maff
Copy link
Member Author

maff commented Mar 7, 2025

Thanks for the feedback!

So if I understand it correctly, in 8.7 we add ad-hoc subprocess support, but the completion condition and "cancel remaining instances" are not available, right?

Exactly. Technically the process could be deployed on 8.7 including these attributes as they are defined in the spec, but the engine would not make use of them. Would you have concerns raising them as an error although the process can be deployed?

@barmac
Copy link
Contributor

barmac commented Mar 7, 2025

Would you have concerns raising them as an error although the process can be deployed?

I think it's the right approach. This way, we can clearly tell the user that certain features are not supported (cf. no surprises).

@barmac
Copy link
Contributor

barmac commented Mar 7, 2025

I've pushed small improvements via 7ba0097, and this is now ready to be merged. Thank you for contributing this!

@barmac barmac merged commit c11ab44 into main Mar 7, 2025
3 checks passed
@barmac barmac deleted the feature/4850-add-ad-hoc-completion-condition-support branch March 7, 2025 16:30
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ad-Hoc Subprocess: Support completionCondition and cancelRemainingInstances attributes
2 participants