-
Notifications
You must be signed in to change notification settings - Fork 916
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
[Workspace] Fix: keep disallowed types when importing with overwrite #6668
[Workspace] Fix: keep disallowed types when importing with overwrite #6668
Conversation
Signed-off-by: SuZhou-Joe <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6668 +/- ##
==========================================
+ Coverage 67.79% 67.81% +0.02%
==========================================
Files 3413 3413
Lines 66755 66770 +15
Branches 10861 10864 +3
==========================================
+ Hits 45254 45282 +28
+ Misses 18857 18845 -12
+ Partials 2644 2643 -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: SuZhou-Joe <[email protected]>
...plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
Outdated
Show resolved
Hide resolved
@SuZhou-Joe could you help me to understand how this PR addressed the above issue? |
Signed-off-by: SuZhou-Joe <[email protected]>
@ruanyl Sure, updated in the description and thanks for calling it out. It requires some context to figure the whole flow out. |
const disallowedSavedObjects: SavedObjectsCheckConflictsObject[] = []; | ||
const allowedSavedObjects: SavedObjectsCheckConflictsObject[] = []; | ||
objects.forEach((item) => { | ||
const isImportIntoWorkspace = !!workspaces?.length; |
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.
nit: this line could move out the forEach loop
} | ||
|
||
allowedSavedObjects.push(item); | ||
return; |
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.
nit: return is not needed 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.
+1 @Hailong-am comments>
For clarification, we are talking about keeping the disallowed types in the destination workspace right?
Approving because seems fine to me
…6668) * fix: keep disallowed types when importing with overwrite Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR #6668 created/updated * feat: update comment Signed-off-by: SuZhou-Joe <[email protected]> * feat: address some minor concern Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit de6a889) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…with overwrite (#6673) * [Workspace] Fix: keep disallowed types when importing with overwrite (#6668) * fix: keep disallowed types when importing with overwrite Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR #6668 created/updated * feat: update comment Signed-off-by: SuZhou-Joe <[email protected]> * feat: address some minor concern Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit de6a889) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Update src/plugins/workspace/server/saved_objects/integration_tests/saved_objects_wrapper_for_check_workspace_conflict.test.ts Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> 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> Co-authored-by: SuZhou-Joe <[email protected]>
…pensearch-project#6668) * fix: keep disallowed types when importing with overwrite Signed-off-by: SuZhou-Joe <[email protected]> * Changeset file for PR opensearch-project#6668 created/updated * feat: update comment Signed-off-by: SuZhou-Joe <[email protected]> * feat: address some minor concern Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
When importing data sources and configuration into a workspace with overwrite: true, we will prevent the creation of such objects. However, to ensure that objects dependent on the disallowed ones continue to function properly, we must leave their references untouched.
How the changes can keep the references untouched.
When user tries to import with
overwrite: true
, the logic will go into https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/import/check_conflicts.ts#L90, and in order to keep the references untouched, we just need to make sure the logic won't go into the branch of https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/server/saved_objects/import/check_conflicts.ts#L105 , which sets a new id reference to the current item. And the result it is consumed comes from thesavedObjectsClient.checkConflicts()
, which can be wrapped by savedObjectsClientWrapper mechanism to intercept special logic on specific objects.Issues Resolved
Screenshot
Before fix
After fix
Testing the changes
There is a integration test case, named
checkConflicts when importing disallowed types
insidesrc/plugins/workspace/server/saved_objects/integration_tests/saved_objects_wrapper_for_check_workspace_conflict.test.ts
to cover this case.Changelog
Check List
yarn test:jest
yarn test:jest_integration