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

fix(database): make to display validation error msg when all cases #20095

Merged
merged 13 commits into from
Aug 24, 2022

Conversation

prosdev0107
Copy link
Contributor

@prosdev0107 prosdev0107 commented May 17, 2022

SUMMARY

The dynamic form to connect to PostgreSQL is not returning connection errors to the user.
No errors display when the error_type is GENERIC_DB_ENGINE_ERROR and so error alerts are displayed at this case.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE:

<removed by @eschutho>

AFTER:

db-error-display.mov

TESTING INSTRUCTIONS

How to reproduce the bug

Please follow the steps with this sample data.


  1. Hover over the + icon > Data > Connect database.
  2. Select PostgreSQL.
  3. Input everything correctly with the exception of the DB name.
  4. Click on CONNECT. No error is shown.
  5. Fix the DB name, and now enter an incorrect username.
  6. Click on CONNECT. No error is shown.
  7. Replace the password to an incorrect value.
  8. Click on CONNECT. No error is shown.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented May 17, 2022

Codecov Report

Merging #20095 (d7428c6) into master (6650076) will increase coverage by 0.00%.
The diff coverage is 45.45%.

@@           Coverage Diff           @@
##           master   #20095   +/-   ##
=======================================
  Coverage   66.35%   66.35%           
=======================================
  Files        1767     1767           
  Lines       67356    67360    +4     
  Branches     7147     7149    +2     
=======================================
+ Hits        44694    44698    +4     
  Misses      20834    20834           
  Partials     1828     1828           
Flag Coverage Δ
javascript 52.12% <45.45%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...onents/ErrorMessage/ErrorMessageWithStackTrace.tsx 60.00% <ø> (ø)
...c/views/CRUD/data/database/DatabaseModal/index.tsx 31.69% <14.28%> (+0.16%) ⬆️
...rontend/src/components/ErrorMessage/ErrorAlert.tsx 90.24% <100.00%> (+0.77%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Left a comment.

@@ -1088,7 +1088,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
let alertErrors: string[] = [];
if (isEmpty(dbErrors) === false) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we also modify this condition to keep the code readable to be consistent? Thanks!

@yousoph
Copy link
Member

yousoph commented May 20, 2022

/testenv up

@github-actions
Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://54.214.197.133:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rusackas
Copy link
Member

rusackas commented Jun 2, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

@rusackas Ephemeral environment spinning up at http://54.149.117.75:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@@ -1086,22 +1090,24 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
// eslint-disable-next-line consistent-return
const errorAlert = () => {
let alertErrors: string[] = [];
if (isEmpty(dbErrors) === false) {
if (isEmpty(dbErrors)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (isEmpty(dbErrors)) {
if (!isEmpty(dbErrors)) {

@yousoph
Copy link
Member

yousoph commented Jun 6, 2022

@prosdev0107
this is looking good! Two small changes:

  1. In the copy, let's put "See more" in quotes. The second sentence should start:

Click "See more" for database-provided... etc etc

  1. Can we move "See more" to the bottom of the error message? See the design guidelines for an example

image

@prosdev0107
Copy link
Contributor Author

@prosdev0107 this is looking good! Two small changes:

  1. In the copy, let's put "See more" in quotes. The second sentence should start:

Click "See more" for database-provided... etc etc

  1. Can we move "See more" to the bottom of the error message? See the design guidelines for an example

image

@yousoph
Thank you for your feedback and Resolved them now!

@yousoph
Copy link
Member

yousoph commented Jun 7, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2022

@yousoph Ephemeral environment spinning up at http://34.219.229.127:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@yousoph
Copy link
Member

yousoph commented Jun 7, 2022

Thanks for the changes! Looking good to me

@@ -1086,22 +1092,24 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
// eslint-disable-next-line consistent-return
const errorAlert = () => {
let alertErrors: string[] = [];
if (isEmpty(dbErrors) === false) {
if (!isEmpty(dbErrors)) {
Copy link
Member

Choose a reason for hiding this comment

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

Previously, this was if (isEmpty(dbErrors) === false)
This new line of if (!isEmpty(dbErrors)) is logically the same, which is great...

However, now I'm a little worried. Our QA round didn't catch anything wrong when this logic was indeed wrong. So... what does this exactly DO, and how do we test it to make sure it's working as expected?

Copy link
Member

Choose a reason for hiding this comment

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

Unit tests to cover this area of code and prove it works would be ideal. Spinning up an ephemeral for manual testing now that CI has passed. Please let us know what manual testing steps would help here.

Copy link
Contributor Author

@prosdev0107 prosdev0107 Jun 13, 2022

Choose a reason for hiding this comment

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

@rusackas
I tried to add the unit test for this case but couldn't do it because of that getValidation function is a call in a hooks and so it is invalid hook call in jest file. And so I add manual testing steps into the Test instructions

@rusackas
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@rusackas Ephemeral environment spinning up at http://35.85.218.215:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@michael-s-molina
Copy link
Member

Hi @prosdev0107. Thanks for the PR. I have two suggestions:

Can we treat invalid usernames and passwords with a generic message? Right now the message confirms that my username is valid and only my password is invalid which raises security concerns. Maybe something like "Invalid credentials" for both the username and password?

Screen Shot 2022-06-27 at 1 35 18 PM

The second suggestion is to automatically scroll to the bottom when there's an error because it's not very clear right now.

@yousoph
Copy link
Member

yousoph commented Jun 27, 2022

@michael-s-molina I believe the message is actually generic right now - even if your username is wrong, it gives you the same message saying that the password provided doesn't work for the username entered

@michael-s-molina
Copy link
Member

@michael-s-molina I believe the message is actually generic right now - even if your username is wrong, it gives you the same message saying that the password provided doesn't work for the username entered

I'm not sure if this is another error but when I try with an unknown user I get another message:

Screen Shot 2022-06-27 at 2 23 22 PM

@yousoph
Copy link
Member

yousoph commented Jun 27, 2022

Oops, you're right! It does look like it's a diff error when the username is wrong

@zhaoyongjie zhaoyongjie self-requested a review June 29, 2022 08:02
Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

This error message is from the database driver, considering security risks(you couldn't know what message will output from drivers), I suggest doing some exception catch in Superset.

others, LGTM

@rusackas
Copy link
Member

rusackas commented Jul 7, 2022

@yousoph is this OK to merge if the errors displayed are at the whim of the database? We can catch/throw an exception as Yongjie suggests - but maybe we can do that in a separate PR? ¯\_(ツ)_/¯

Otherwise, @prosdev0107 I think this just needs a rebase or conflict resolution

@rusackas
Copy link
Member

rusackas commented Aug 9, 2022

Conflicts resolved... let's merge if/when CI passes

@rusackas rusackas merged commit d568999 into apache:master Aug 24, 2022
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

sadpandajoe added a commit to preset-io/superset that referenced this pull request Aug 31, 2022
sadpandajoe added a commit to preset-io/superset that referenced this pull request Aug 31, 2022
rusackas pushed a commit that referenced this pull request Aug 31, 2022
sadpandajoe added a commit to preset-io/superset that referenced this pull request Sep 1, 2022
… error msg when all … (apache#21277)

(cherry picked from commit 4b22137)
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Sep 6, 2022
…pache#20095)

* fix(database): make to display validation error msg when all cases

* fix(db): make to update the alert error condition

* fix(db): make to add error detail display

* fix(db): make to update error alert display by superset error style guide.

* fix(db): make to style modal header title with h4

* fix(db): make to place see more on bottom instead of top

* fix(db): make to fix shortly

* fix(db): make to fix lint issue

Co-authored-by: Evan Rusackas <evan@preset.io>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels Preset-Patch size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants