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: Avoid 500 if end users write bad SQL #26638

Merged
merged 3 commits into from
Jan 17, 2024
Merged

Conversation

Khrol
Copy link
Contributor

@Khrol Khrol commented Jan 16, 2024

SUMMARY

While end users deal with Superset+Trino we are observing quite some 500 errors on backend.

For example, a user can create/edit a virtual dataset and make mistakes in SQL. Trino client raises the exception and it goes uncaught to 500.

If SupersetDBAPIProgrammingError is raised it's better to return 400 to the end user because nothing bad happens with Superset instance.

I don't know what to do with SupersetDBAPIError in general. If underlying Database has problems, should it lead to Superset's 500 or it's ok to stay with 400 because Superset itself works fine.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7ca6d8c) 69.18% compared to head (d7443c4) 69.06%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26638      +/-   ##
==========================================
- Coverage   69.18%   69.06%   -0.13%     
==========================================
  Files        1948     1938      -10     
  Lines       76036    75596     -440     
  Branches     8478     8478              
==========================================
- Hits        52604    52208     -396     
+ Misses      21265    21221      -44     
  Partials     2167     2167              
Flag Coverage Δ
hive 53.58% <12.50%> (-0.11%) ⬇️
mysql 77.88% <12.50%> (-0.16%) ⬇️
postgres 77.98% <12.50%> (-0.19%) ⬇️
presto 53.53% <12.50%> (-0.11%) ⬇️
python 82.77% <100.00%> (-0.09%) ⬇️
sqlite 77.57% <12.50%> (-0.20%) ⬇️
unit 55.85% <100.00%> (-0.04%) ⬇️

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
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

We have lots of these unnecessary 500s, which makes logs noisy, thanks for cleaning these up 👍 While the new Trino exception mappings are probably very uncontroversial, I'd like a few extra eyes on changing the status type of SupersetDBAPIProgrammingError. However, I feel 400 is probably a better default than 500 for that one.

@john-bodley john-bodley added the review:checkpoint Last PR reviewed during the daily review standup label Jan 16, 2024
@pull-request-size pull-request-size bot added size/M and removed size/S labels Jan 16, 2024
@Khrol
Copy link
Contributor Author

Khrol commented Jan 16, 2024

While the new Trino exception mappings are probably very uncontroversial

I've initially submitted Draft PR to see at least some feedback. The situation there is a bit more complex and I've pushed more code.

If underlying Database has problems, should it lead to Superset's 500 or it's ok to stay with 400 because Superset itself works fine?

I don't know how to interpret 500 errors with connection to underlying source Databases... 🤔

@Khrol Khrol marked this pull request as ready for review January 16, 2024 19:42
@john-bodley john-bodley merged commit 80a6e25 into apache:master Jan 17, 2024
53 checks passed
@john-bodley john-bodley removed the review:checkpoint Last PR reviewed during the daily review standup label Jan 17, 2024
@Khrol Khrol deleted the trino_500 branch January 17, 2024 18:00
@michael-s-molina michael-s-molina added v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Jan 18, 2024
michael-s-molina pushed a commit that referenced this pull request Jan 18, 2024
Muhammed-baban pushed a commit to intellica-tech/reporting-tool that referenced this pull request Jan 19, 2024
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Feb 12, 2024
@mistercrunch mistercrunch added 🍒 3.0.4 🍒 3.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 8, 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 size/M v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch 🍒 3.0.4 🍒 3.1.1 🍒 3.1.2 🍒 3.1.3 🚢 4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants