Skip to content
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: optimization on handling invalid workspace id in workspace_ui_settings wrapper #6669

Merged

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Apr 29, 2024

Description

A new wrapper, workspace_ui_settings, has been introduced by workspace plugin. When a user attempts to access an invalid workspace, OSD will display plain JSON instead of a user-friendly web page. This PR primarily addresses the issue by adding a try catch wrapper to the client.get method.

Issues Resolved

Screenshot

Before fix

image

After fix

image

As well as an error log in OSD:

image

Testing the changes

  • Use the branch to bootstrap and enable workspace feature flag
  • Type an invalid url like http://localhost:5601/w/123/app/workspace_overview
  • An error page with error message saying: Saved object [workspace/123] not found should be found.

Changelog

  • fix: optimization on handling invalid workspace id in workspace_ui_settings wrapper

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: SuZhou-Joe <[email protected]>
@SuZhou-Joe SuZhou-Joe added bug Something isn't working workspace v2.14.0 labels Apr 29, 2024
Copy link

codecov bot commented Apr 29, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.79%. Comparing base (460428c) to head (39d74fb).
Report is 468 commits behind head on main.

Files with missing lines Patch % Lines
...ed_objects/workspace_ui_settings_client_wrapper.ts 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6669   +/-   ##
=======================================
  Coverage   67.79%   67.79%           
=======================================
  Files        3413     3413           
  Lines       66755    66760    +5     
  Branches    10861    10863    +2     
=======================================
+ Hits        45254    45258    +4     
  Misses      18857    18857           
- Partials     2644     2645    +1     
Flag Coverage Δ
Linux_1 33.19% <87.50%> (+<0.01%) ⬆️
Linux_2 55.63% <ø> (ø)
Linux_3 45.24% <ø> (ø)
Linux_4 34.91% <ø> (ø)
Windows_1 33.21% <87.50%> (+<0.01%) ⬆️
Windows_2 55.59% <ø> (ø)
Windows_3 45.26% <ø> (ø)
Windows_4 34.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

SuZhou-Joe and others added 3 commits April 29, 2024 14:46
…gs_client_wrapper.ts

Co-authored-by: Yulong Ruan <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
configObject.attributes = {
...configObject.attributes,
...(workspaceObject ? workspaceObject.attributes.uiSettings : {}),
};

configObject.attributes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems the configObject.attributes has already been set above. Why we need to assign it again?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, remove the useless assign.

Signed-off-by: SuZhou-Joe <[email protected]>
@SuZhou-Joe SuZhou-Joe merged commit 29a09b0 into opensearch-project:main Apr 29, 2024
69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 29, 2024
…kspace_ui_settings wrapper (#6669)

* fix: invalid workspace id

Signed-off-by: SuZhou-Joe <[email protected]>

* Changeset file for PR #6669 created/updated

* Update src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts

Co-authored-by: Yulong Ruan <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* feat: update error message

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: remove useless code

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>
Co-authored-by: Yulong Ruan <[email protected]>
(cherry picked from commit 29a09b0)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit that referenced this pull request Apr 30, 2024
…kspace_ui_settings wrapper (#6669) (#6672)

* fix: invalid workspace id



* Changeset file for PR #6669 created/updated

* Update src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts




* feat: update error message



* fix: type error



* feat: remove useless code



---------




(cherry picked from commit 29a09b0)

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: Yulong Ruan <[email protected]>
LDrago27 pushed a commit to LDrago27/OpenSearch-Dashboards that referenced this pull request Jun 3, 2024
…kspace_ui_settings wrapper (opensearch-project#6669)

* fix: invalid workspace id

Signed-off-by: SuZhou-Joe <[email protected]>

* Changeset file for PR opensearch-project#6669 created/updated

* Update src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts

Co-authored-by: Yulong Ruan <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* feat: update error message

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: remove useless code

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>
Co-authored-by: Yulong Ruan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants