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]feat: validate workspace when find objects #8268

Merged

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Sep 20, 2024

Description

We need to validate the workspace ids users pass, if it is not valid, we should just throw a 400 error and save the resource of our search engine.

Issues Resolved

Screenshot

Testing the changes

Changelog

  • feat: validate if the workspaces param is valid or not when consume it in the 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

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.11%. Comparing base (18875f7) to head (e887bd7).
Report is 206 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8268      +/-   ##
==========================================
+ Coverage   64.04%   64.11%   +0.07%     
==========================================
  Files        3740     3744       +4     
  Lines       88582    88857     +275     
  Branches    13791    13852      +61     
==========================================
+ Hits        56731    56974     +243     
- Misses      31253    31270      +17     
- Partials      598      613      +15     
Flag Coverage Δ
Linux_1 30.09% <100.00%> (+0.04%) ⬆️
Linux_2 58.85% <ø> (+0.06%) ⬆️
Linux_3 40.33% <ø> (-0.05%) ⬇️
Linux_4 31.57% <ø> (+0.10%) ⬆️
Windows_1 30.10% <100.00%> (+0.03%) ⬆️
Windows_2 58.80% <ø> (+0.06%) ⬆️
Windows_3 40.33% <ø> (-0.06%) ⬇️
Windows_4 31.57% <ø> (+0.10%) ⬆️

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.

Signed-off-by: SuZhou-Joe <[email protected]>
);
: this.formatWorkspaceIdParams(wrapperOptions.request, options);
if (finalOptions.workspaces?.length) {
const workspaceList = await this.workspaceClient.list(
Copy link
Member

Choose a reason for hiding this comment

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

Shall we simply call wrapperOptions.client.find with WORKSPACE_TYPE to get the the workspace list? Just thinking might be better to not introduce another dependency to saved object client wrapper.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can not because workspace is a hidden type.

@SuZhou-Joe SuZhou-Joe merged commit b6eb1a0 into opensearch-project:main Oct 2, 2024
69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 2, 2024
* feat: validate workspace when find objects

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

* Changeset file for PR #8268 created/updated

* fix: type error

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

* feat: add unit test

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

* feat: address some comments

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

* feat: optimize performance

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 b6eb1a0)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Hailong-am pushed a commit that referenced this pull request Oct 2, 2024
* feat: validate workspace when find objects



* Changeset file for PR #8268 created/updated

* fix: type error



* feat: add unit test



* feat: address some comments



* feat: optimize performance



---------



(cherry picked from commit b6eb1a0)

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>
SuZhou-Joe pushed a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Oct 3, 2024
…ject#8268) (opensearch-project#8431)

* feat: validate workspace when find objects



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

* fix: type error



* feat: add unit test



* feat: address some comments



* feat: optimize performance



---------



(cherry picked from commit b6eb1a0)

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>
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.

4 participants