-
Notifications
You must be signed in to change notification settings - Fork 0
Filter by uniqueness after filtering by scope #56
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
Conversation
* also, don't filter out external variables Closes #54
1060cb8 to
02e9c98
Compare
There was a problem hiding this 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
BaseVariableResolverto 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.
lib/zeebe/VariableResolver.js
Outdated
| if ( | ||
| is(moddleElement, 'zeebe:Output') && | ||
| v.provider.find(extractor => extractor !== this._baseExtractor) | ||
| (variable.provider || []).find(extractor => extractor !== this._baseExtractor) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
1f49513 to
22f4dec
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
c05dc2a to
d6af0a6
Compare
| // 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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Powered by Flip + 🤖 ❤️
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:
@bpmn-io/srtoolCloses {LINK_TO_ISSUE}orRelated to {LINK_TO_ISSUE}