[Workspace]Fix maximum call stack error in use case service#7817
Merged
SuZhou-Joe merged 7 commits intoopensearch-project:mainfrom Aug 24, 2024
Merged
Conversation
Signed-off-by: Lin Wang <wonglam@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7817 +/- ##
=======================================
Coverage 63.82% 63.83%
=======================================
Files 3658 3658
Lines 81286 81288 +2
Branches 12975 12974 -1
=======================================
+ Hits 51884 51888 +4
+ Misses 26217 26216 -1
+ Partials 3185 3184 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Lin Wang <wonglam@amazon.com>
SuZhou-Joe
reviewed
Aug 23, 2024
Comment on lines
+263
to
+280
| const compareFeatures = ( | ||
| features1: WorkspaceUseCaseFeature[], | ||
| features2: WorkspaceUseCaseFeature[] | ||
| ) => { | ||
| const featureSerialize = ({ id, title }: WorkspaceUseCaseFeature) => `${id}-${title}`; | ||
| const features1Set = new Set(features1.map(featureSerialize)); | ||
| const features2Set = new Set(features2.map(featureSerialize)); | ||
| if (features1Set.size !== features2Set.size) { | ||
| return false; | ||
| } | ||
| for (const feature of features1Set) { | ||
| if (!features2Set.has(feature)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| }; | ||
|
|
Member
There was a problem hiding this comment.
Perhaps we can simplify the compare by sorting the serialized array and see if JSON.stringify(sortArray) equals?
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
ruanyl
approved these changes
Aug 23, 2024
SuZhou-Joe
approved these changes
Aug 24, 2024
Contributor
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7817-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 452b65dceff7c9a2f283f0dda0793d0a4a8f3aba
# Push it to GitHub
git push --set-upstream origin backport/backport-7817-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.xThen, create a pull request where the |
opensearch-trigger-bot bot
pushed a commit
that referenced
this pull request
Aug 26, 2024
* Fix maximum call stack error in UseCaseService Signed-off-by: Lin Wang <wonglam@amazon.com> * Changeset file for PR #7817 created/updated * Improve UT coverage Signed-off-by: Lin Wang <wonglam@amazon.com> * Refactor compare with sort Signed-off-by: Lin Wang <wonglam@amazon.com> * Refactor compareFeatures Signed-off-by: Lin Wang <wonglam@amazon.com> * Add ut for multi same features Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 452b65d) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl
pushed a commit
that referenced
this pull request
Aug 26, 2024
…7840) * Fix maximum call stack error in UseCaseService * Changeset file for PR #7817 created/updated * Improve UT coverage * Refactor compare with sort * Refactor compareFeatures * Add ut for multi same features --------- (cherry picked from commit 452b65d) Signed-off-by: Lin Wang <wonglam@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is for fixing maximum call stack error in use case service, separate a function to compare features using
sortinstead of usingArray.property.some.The root cause of this bug should be error features compare result see below example:
The result should be
truewhich means two use case should be equal. But the old compare logic will returnfalse. We should changeb.features.sometob.features.every, then the result would be correct. Usingsomeandeveryto implement the compare logic would be a little bit complicated, it can't handle duplicate features. So we change to usesortto compare the use case.Issues Resolved
#7820
Screenshot
No UI changes
Testing the changes
yarn osd bootstrap --single-version ignoreconfig/opensearch_dashboards.ymlyarn start --no-base-pathMaximum call stack errorin the consoleChangelog
Check List
yarn test:jestyarn test:jest_integration