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

[Worksapce]Add blank check for workspace name #7512

Merged

Conversation

Hailong-am
Copy link
Collaborator

@Hailong-am Hailong-am commented Jul 26, 2024

Description

Add blank or empty check for workspace name

Issues Resolved

#7280

Screenshot

when input a blank workspace name, validation will fail

image

Testing the changes

Changelog

  • fix: [Workspace]add workspace name blank/empty 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

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

codecov bot commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.64%. Comparing base (5f19c37) to head (6188f35).
Report is 1 commits behind head on main.

Files Patch % Lines
src/plugins/workspace/server/routes/index.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7512      +/-   ##
==========================================
- Coverage   63.64%   63.64%   -0.01%     
==========================================
  Files        3629     3629              
  Lines       79522    79525       +3     
  Branches    12604    12605       +1     
==========================================
+ Hits        50611    50612       +1     
- Misses      25842    25844       +2     
  Partials     3069     3069              
Flag Coverage Δ
Linux_1 30.76% <50.00%> (+<0.01%) ⬆️
Linux_2 55.58% <ø> (ø)
Linux_3 40.22% <ø> (+<0.01%) ⬆️
Linux_4 31.57% <ø> (ø)
Windows_1 30.77% <50.00%> (+<0.01%) ⬆️
Windows_2 55.53% <ø> (ø)
Windows_3 40.23% <ø> (ø)
Windows_4 31.57% <ø> (ø)

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.

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

const workspaceNameSchema = schema.string({
validate(value) {
if (!value || value.trim().length === 0) {
return "can't be empty or blank.";
Copy link
Member

@SuZhou-Joe SuZhou-Joe Jul 26, 2024

Choose a reason for hiding this comment

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

Not sure if the error message is clear enough for customers to understand what happens here, and from the description of the input, it seems space are valid input though the name can not be pure spaces.

And should we wrap it with i18n?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

field name will prepend to actual message, the whole error message will be

{
 "statusCode": 400,
 "error": "Bad Request",
 "message": "[request body.attributes.name]: can't be empty or blank."
}

And should we wrap it with i18n?

as the default validation message of schema.string()haven't been wrapped by i18n. i think we can keep it same

@SuZhou-Joe SuZhou-Joe merged commit b5f4942 into opensearch-project:main Aug 8, 2024
68 of 69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 8, 2024
* add workspace blank check

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

* Changeset file for PR #7512 created/updated

* add integ test

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

* Changeset file for PR #7512 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 b5f4942)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit that referenced this pull request Aug 9, 2024
* add workspace blank check



* Changeset file for PR #7512 created/updated

* add integ test



* Changeset file for PR #7512 created/updated

---------



(cherry picked from commit b5f4942)

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