Skip to content

Conversation

@philippfromme
Copy link
Contributor

@philippfromme philippfromme commented Sep 10, 2025

Proposed Changes

When two input parameters with the same target exist on two elements and I resolve the variables for each I don't want an input variable to be missing due to an early uniqueBy which removes one of the two variables even though it might be the one with the correct scope.

Closes #54

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}

Copilot

This comment was marked as outdated.

* also, don't filter out external variables

Closes #54
Copilot

This comment was marked as outdated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where input variables were incorrectly filtered out when two elements with the same variable name existed but had different scopes. The change ensures variables are filtered by scope first, then by uniqueness, preserving variables with the correct scope.

Key Changes

  • Modified the filtering logic in BaseVariableResolver to filter by scope before applying uniqueness constraints
  • Added a new test case to verify variables with the same name but different scopes are not merged
  • Updated the BPMN test fixture to include an additional ServiceTask for testing scope differentiation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/base/VariableResolver.js Refactored variable filtering logic to preserve scope-specific variables and handle external variables correctly
test/spec/zeebe/ZeebeVariableResolver.spec.js Added test case for different scopes with same variable name and updated existing test description
test/fixtures/zeebe/simple.bpmn Added ServiceTask_2 to support testing of multiple scopes with same variable names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (
is(moddleElement, 'zeebe:Output') &&
v.provider.find(extractor => extractor !== this._baseExtractor)
(variable.provider || []).find(extractor => extractor !== this._baseExtractor)
Copy link
Member

Choose a reason for hiding this comment

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

What "bug" do we fix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really anything. It's save to assume that provider is always going to exist. But Copilot complained.

Copy link
Member

Choose a reason for hiding this comment

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

Why does co-pilot complain? Let's fix the types if that is the issue, or otherwise build on existing contracts and not introduce these arbitrary null checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check if we can fix the types.

Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Consider to unbuild the unneeded null check around providers.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@philippfromme philippfromme merged commit 0e95947 into main Sep 15, 2025
5 checks passed
@philippfromme philippfromme deleted the 54-input-parameter-bug branch September 15, 2025 12:16
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Sep 15, 2025
// if not external, keep only if first of its name
return reversedVariables.find(v => v.name === variable.name) === variable;
// if not external, keep only the first occurrence of each name
if (!seenNames.has(variable.name)) {
Copy link
Member

Choose a reason for hiding this comment

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

Powered by Flip + 🤖 ❤️

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.

Variables with different scope and same name as other variable might get removed

2 participants