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

Display MySQL user defined error in API Key UI #4590

Merged

Conversation

kentakozuka
Copy link
Member

@kentakozuka kentakozuka commented Sep 4, 2023

What this PR does / why we need it:

Screenshot 2023-09-04 at 12 22 49

Which issue(s) this PR fixes:

Fixes partof #4589

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

dispatch(addToast({ message: GENERATE_API_KEY_SUCCESS }));
});
dispatch(generateAPIKey(values))
.then(unwrapResult)
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes an existing bug that success toast is displayed even if a request fails.

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Patch coverage: 50.00% and project coverage change: +0.03% 🎉

Comparison is base (d9d30af) 29.95% compared to head (794bc92) 29.98%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4590      +/-   ##
==========================================
+ Coverage   29.95%   29.98%   +0.03%     
==========================================
  Files         220      220              
  Lines       25933    25948      +15     
==========================================
+ Hits         7767     7781      +14     
  Misses      17518    17518              
- Partials      648      649       +1     
Files Changed Coverage Δ
pkg/datastore/datastore.go 0.00% <ø> (ø)
pkg/datastore/mysql/mysql.go 11.11% <0.00%> (-0.21%) ⬇️
pkg/app/server/grpcapi/grpcapi.go 17.96% <81.81%> (+10.65%) ⬆️

... and 2 files with indirect coverage changes

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

}
if errors.Is(err, datastore.ErrUserDefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have to change from switch case to multiple if 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

If we generate an error with a message from MySQL, handling errors with a switch cannot work properly. That's why I had to change it to multi-if blocks.

Copy link
Member

Choose a reason for hiding this comment

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

Which means the switch block can not check the type of datastore.ErrUserDefined error 🤔 It's a bit weird to me. Btw, how about adding test for this function. Looks like this function is testable without mocking anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

When an error message from MySQL is added to datastore.ErrUserDefined, checking with the switch block does not work because the new error is no longer the same as datastore.ErrUserDefined.

I agree with you to add tests for it 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Added tests.

Signed-off-by: Kenta Kozuka <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>
@kentakozuka
Copy link
Member Author

@khanhtc1202 Added tests 👍

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

Great 🚀

@kentakozuka kentakozuka merged commit 0cf1f84 into pipe-cd:master Sep 7, 2023
13 checks passed
@kentakozuka kentakozuka deleted the display-user-defined-error-mysql branch September 7, 2023 09:41
khanhtc1202 pushed a commit that referenced this pull request Oct 11, 2023
* Display MySQL user defined error in UI

Signed-off-by: Kenta Kozuka <[email protected]>

* Fix Unexpected empty arrow function

Signed-off-by: Kenta Kozuka <[email protected]>

* Add tests

Signed-off-by: Kenta Kozuka <[email protected]>

* Run subtests in parallel

Signed-off-by: Kenta Kozuka <[email protected]>

---------

Signed-off-by: Kenta Kozuka <[email protected]>
khanhtc1202 added a commit that referenced this pull request Oct 11, 2023
* Display MySQL user defined error in API Key UI (#4590)

* Display MySQL user defined error in UI

Signed-off-by: Kenta Kozuka <[email protected]>

* Fix Unexpected empty arrow function

Signed-off-by: Kenta Kozuka <[email protected]>

* Add tests

Signed-off-by: Kenta Kozuka <[email protected]>

* Run subtests in parallel

Signed-off-by: Kenta Kozuka <[email protected]>

---------

Signed-off-by: Kenta Kozuka <[email protected]>

* Display MySQL user defined error of piped, command, and application (#4597)

Signed-off-by: Kenta Kozuka <[email protected]>

* Add service tags as takset task on create (#4598)

Signed-off-by: khanhtc1202 <[email protected]>

* [ECS] Fix remove all previous active tasksets on QuickSync (#4600)

* Remove previous ACTIVE tasksets if present on quicksync

Signed-off-by: khanhtc1202 <[email protected]>

* Remove GetPrimaryTaskSet interface

Signed-off-by: khanhtc1202 <[email protected]>

---------

Signed-off-by: khanhtc1202 <[email protected]>

* Fix unable to fetch ECS taskset tags (#4605)

Signed-off-by: khanhtc1202 <[email protected]>

* Support recreate for ECS tasks (#4608)

* Support singleton ECS task

Signed-off-by: khanhtc1202 <[email protected]>

* Rename singleton to recreate

Signed-off-by: khanhtc1202 <[email protected]>

---------

Signed-off-by: khanhtc1202 <[email protected]>

---------

Signed-off-by: Kenta Kozuka <[email protected]>
Signed-off-by: khanhtc1202 <[email protected]>
Co-authored-by: Kenta Kozuka <[email protected]>
moko-poi pushed a commit to moko-poi/pipecd that referenced this pull request Nov 3, 2023
* Display MySQL user defined error in UI

Signed-off-by: Kenta Kozuka <[email protected]>

* Fix Unexpected empty arrow function

Signed-off-by: Kenta Kozuka <[email protected]>

* Add tests

Signed-off-by: Kenta Kozuka <[email protected]>

* Run subtests in parallel

Signed-off-by: Kenta Kozuka <[email protected]>

---------

Signed-off-by: Kenta Kozuka <[email protected]>
Signed-off-by: moko-poi <[email protected]>
sZma5a pushed a commit to sZma5a/pipecd that referenced this pull request Nov 5, 2023
* Display MySQL user defined error in UI

Signed-off-by: Kenta Kozuka <[email protected]>

* Fix Unexpected empty arrow function

Signed-off-by: Kenta Kozuka <[email protected]>

* Add tests

Signed-off-by: Kenta Kozuka <[email protected]>

* Run subtests in parallel

Signed-off-by: Kenta Kozuka <[email protected]>

---------

Signed-off-by: Kenta Kozuka <[email protected]>
@github-actions github-actions bot mentioned this pull request Dec 1, 2023
@github-actions github-actions bot mentioned this pull request Feb 6, 2024
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.

2 participants