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 workspace name duplication check #6776

Merged

Conversation

Hailong-am
Copy link
Collaborator

@Hailong-am Hailong-am commented May 13, 2024

Description

enclose workspace name with double quotes when doing duplication check, so that it will not interpret by simply query syntax and do match it with exact match (workspace.name field type is keyword)

GET .kibana/_search
{
  "profile": "true", 
  "query": {
    "simple_query_string": {
      "query": "\"demo workspace\"",
      "fields": ["workspace.name"]
    }
  }
}

It will convert to TermQuery that's exact match.

  "profile": {
    "shards": [
      {
        "id": "[qYfwnwnoTiqalgsnAT9rjA][.kibana_12][0]",
        "inbound_network_time_in_millis": 0,
        "outbound_network_time_in_millis": 0,
        "searches": [
          {
            "query": [
              {
                "type": "TermQuery",
                "description": "workspace.name:demo workspace",
                "time_in_nanos": 9585,
                "breakdown": {
                  ...
                }
              }
            ]
           ...
          }
        ],
        "aggregations": []
      }
    ]
  }

Issues Resolved

#6480

Screenshot

Testing the changes

Changelog

  • fix: fix workspace name duplication check

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
Contributor

❌ Changelog Entry Missing Hyphen

Changelog entries must begin with a hyphen (-).

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.55%. Comparing base (f728b5a) to head (f9d5ed5).
Report is 436 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6776   +/-   ##
=======================================
  Coverage   67.55%   67.55%           
=======================================
  Files        3428     3428           
  Lines       67340    67340           
  Branches    10994    10994           
=======================================
  Hits        45494    45494           
  Misses      19176    19176           
  Partials     2670     2670           
Flag Coverage Δ
Linux_1 33.04% <ø> (ø)
Linux_2 55.13% <ø> (ø)
Linux_3 45.16% <ø> (ø)
Linux_4 34.73% <ø> (ø)
Windows_1 33.06% <ø> (ø)
Windows_2 55.10% <ø> (ø)
Windows_3 45.17% <ø> (ø)
Windows_4 34.73% <ø> (ø)

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.

@Hailong-am
Copy link
Collaborator Author

Hailong-am commented May 13, 2024

link check error not related to this change, it will fixed by #6771

### Errors in src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/url_template_flyout.tsx

* [ERR] [http://www.site.com/images/favicon.ico](http://www.site.com/images/favicon.ico) | Failed: Too many redirects: error following redirect for url (https://www.salesforce.com/platform/)
* [ERR] [http://www.site.com/](http://www.site.com/) | Failed: Too many redirects: error following redirect for url (https://www.salesforce.com/platform/)

Copy link
Contributor

@wanglam wanglam left a comment

Choose a reason for hiding this comment

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

LGTM

@Hailong-am Hailong-am changed the title Fix workspace name duplication check [Workspace] Fix workspace name duplication check May 13, 2024
@@ -95,7 +95,7 @@ export class WorkspaceClient implements IWorkspaceClientImpl {
const existingWorkspaceRes = await this.getScopedClientWithoutPermission(requestDetail)?.find(
{
type: WORKSPACE_TYPE,
search: attributes.name,
search: `"${attributes.name}"`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this search for a workspace including this exact phrase or one that is an exact match?

Copy link
Collaborator Author

@Hailong-am Hailong-am May 16, 2024

Choose a reason for hiding this comment

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

It depends on the field type. For my case, since workspace.name filed type is keyword, it will convert to TermQuery that's exact match. To make the PR description more clear, it add an example query with profile enabled.

@SuZhou-Joe SuZhou-Joe merged commit f74eb24 into opensearch-project:main May 21, 2024
69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 21, 2024
* fix workspace name duplication check

Signed-off-by: Hailong Cui <[email protected]>

* Changeset file for PR #6776 created/updated

---------

Signed-off-by: Hailong Cui <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit f74eb24)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit that referenced this pull request May 27, 2024
* fix workspace name duplication check



* Changeset file for PR #6776 created/updated

---------



(cherry picked from commit f74eb24)

Signed-off-by: Hailong Cui <[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>
LDrago27 pushed a commit to LDrago27/OpenSearch-Dashboards that referenced this pull request Jun 3, 2024
…6776)

* fix workspace name duplication check

Signed-off-by: Hailong Cui <[email protected]>

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

---------

Signed-off-by: Hailong Cui <[email protected]>
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.

7 participants