-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add parameter multiplicity validation for service registration #1538
Add parameter multiplicity validation for service registration #1538
Conversation
🦋 Changeset detectedLatest commit: efea3c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report
@@ Coverage Diff @@
## master #1538 +/- ##
==========================================
+ Coverage 40.57% 40.59% +0.01%
==========================================
Files 1264 1264
Lines 56295 56284 -11
Branches 12718 12708 -10
==========================================
+ Hits 22843 22847 +4
+ Misses 33370 33355 -15
Partials 82 82
|
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.
please confirm your test. Thanks
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
this.editorStore.applicationStore.notifyError( | ||
`Multiplicy of ${params.map( | ||
(p) => p.name, | ||
)} is/are [1..*], which is not in the allowed range for MANY multiplicity. Please use [*], [0..*] instead.`, |
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.
Lets confirm the list of accepted Multiplicies
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
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.
please ensure error message prints expected message
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
...tion-studio/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts
Outdated
Show resolved
Hide resolved
fd5e645
to
4eee71f
Compare
); | ||
assertTrue( | ||
invalidParams.length === 0, | ||
`${invalidParams.map( |
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.
Parameters p1:[1..], p2:[1..] have unsupported multiplicities
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.
) | ||
.filter(filterByType(VariableExpression)) | ||
.filter( | ||
(p) => !supportedServiceParamMultiplicties.includes(p.multiplicity), |
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.
don't think we can always assume multiplicity comes from the same graph and the multiplicity index. The most appropriate check here is to do the comparison by lower
and upper
bounds. The fact we cache multiplicities in the graph is just small optimization, we don't require other coders to have to know about it. I think it's best to create a comparator helper for multiplicity and use this. I almost guarantee this might cause a bug some day 🤷
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.
yeah in terms of bugs i think we could just use comparator. we should try to always use the getMultiplicity though so they are still the same object.
but in this casse if they happen to be different objects we should still not allow the ones with unsupported multiplicities.
62a625c
to
8a435af
Compare
improve condition and error messages improve error message add a comparator for multiplicity
8a435af
to
cfe3a4c
Compare
Summary
Add a parameter multiplicity validation when registering a service.
For MANY multiplicity, the allowed range is [0..*, .., ].
If users try to use [1..] or others that have *, Studio will throw an error notification.
Fixes #1539
Depends on #1543
How did you test this change?