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: Unhandled exception Str Column Type #22147

Merged
merged 4 commits into from
Nov 21, 2022

Conversation

sinhashubham95
Copy link
Contributor

SUMMARY

The metric is a list of Any, so that may or may not have the attribute get. This pull request adds a check for that and avoids the APIs using the same throwing internal server error.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

NA

TESTING INSTRUCTIONS

NA

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

@sinhashubham95
Copy link
Contributor Author

@villebro can you please check this?

@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #22147 (8ec8622) into master (394fb2f) will increase coverage by 13.77%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           master   #22147       +/-   ##
===========================================
+ Coverage   53.22%   67.00%   +13.77%     
===========================================
  Files        1833     1833               
  Lines       69935    69932        -3     
  Branches     7571     7571               
===========================================
+ Hits        37221    46855     +9634     
+ Misses      30755    21118     -9637     
  Partials     1959     1959               
Flag Coverage Δ
hive 52.60% <0.00%> (+<0.01%) ⬆️
mysql 78.14% <100.00%> (?)
postgres 78.21% <100.00%> (?)
presto 52.50% <0.00%> (?)
python 81.39% <100.00%> (+28.79%) ⬆️
sqlite 76.66% <100.00%> (?)
unit 50.90% <0.00%> (?)

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

Impacted Files Coverage Δ
superset/connectors/base/models.py 87.12% <100.00%> (+22.66%) ⬆️
superset/config.py 91.84% <0.00%> (+0.62%) ⬆️
superset/views/database/views.py 31.36% <0.00%> (+0.90%) ⬆️
superset/reports/models.py 100.00% <0.00%> (+2.00%) ⬆️
superset/initialization/__init__.py 91.00% <0.00%> (+2.00%) ⬆️
superset/databases/commands/exceptions.py 96.92% <0.00%> (+3.07%) ⬆️
superset/migrations/shared/utils.py 35.48% <0.00%> (+3.22%) ⬆️
superset/sql_lab.py 82.12% <0.00%> (+3.42%) ⬆️
superset/exceptions.py 91.30% <0.00%> (+3.47%) ⬆️
superset/charts/data/commands/get_data_command.py 100.00% <0.00%> (+3.70%) ⬆️
... and 324 more

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

Comment on lines 316 to 318
(
(hasattr(metric, "get") and metric.get("column")) or {}
).get("column_name")
Copy link
Member

Choose a reason for hiding this comment

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

On line 314 we're already calling a type guard making sure that the type is in fact AdhocMetric. So it appears there may be something wrong either in the declaration of the AdhocMetric type or the type guard. Can you post the full stack trace of the error you're seeing and see if we need to update either one of those instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@villebro sorry for the late reply. As you mentioned correctly, I missed the check for AdhocMetric. The issue was not with metric param, rather with column. Added a check around that.

@sinhashubham95 sinhashubham95 changed the title fix: Unhandled exception for Any metric type fix: Unhandled exception Str Column Type Nov 20, 2022
@sinhashubham95
Copy link
Contributor Author

@villebro please check.

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.

One minor improvement proposal to further simplify the code

superset/connectors/base/models.py Outdated Show resolved Hide resolved
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
@sinhashubham95
Copy link
Contributor Author

@villebro applied the requested changes. Please check.

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.

LGTM, thanks for the fix!

@villebro villebro merged commit cc38400 into apache:master Nov 21, 2022
@sinhashubham95 sinhashubham95 deleted the connectors-models-fix branch November 21, 2022 10:14
@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 size/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants