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: accept null params for validation #17788

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

eschutho
Copy link
Member

@eschutho eschutho commented Dec 17, 2021

SUMMARY

If a null value is passed into the template Params for sql lab, the validation blows up.

json.loads("null") returns None.

TESTING INSTRUCTIONS

Type null for a template param and type in the sql lab editor and watch the network requests. The validate_sql_json requests should not be 500s.

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

@eschutho eschutho force-pushed the elizabeth/fix-validator-params branch from 05d93f4 to f0ebed9 Compare December 17, 2021 03:50
@sadpandajoe
Copy link
Member

🏷️ 2021.49

@eschutho
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@eschutho Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

@eschutho Ephemeral environment creation failed. Please check the Actions logs for details.

@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

Merging #17788 (f0ebed9) into master (2ae83fa) will increase coverage by 0.14%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17788      +/-   ##
==========================================
+ Coverage   68.85%   68.99%   +0.14%     
==========================================
  Files        1597     1597              
  Lines       65251    65357     +106     
  Branches     6950     6950              
==========================================
+ Hits        44927    45093     +166     
+ Misses      18439    18379      -60     
  Partials     1885     1885              
Flag Coverage Δ
hive 81.80% <0.00%> (+0.11%) ⬆️
mysql 82.18% <0.00%> (+0.07%) ⬆️
postgres 82.23% <0.00%> (+0.11%) ⬆️
presto 82.10% <0.00%> (?)
python 82.72% <0.00%> (+0.26%) ⬆️
sqlite 81.91% <0.00%> (+0.11%) ⬆️

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

Impacted Files Coverage Δ
superset/views/core.py 77.80% <0.00%> (+0.42%) ⬆️
superset/dashboards/dao.py 95.55% <0.00%> (-0.54%) ⬇️
superset/datasets/commands/importers/v1/utils.py 58.33% <0.00%> (-0.50%) ⬇️
superset/db_engine_specs/postgres.py 97.27% <0.00%> (-0.10%) ⬇️
superset/migrations/env.py 0.00% <0.00%> (ø)
superset/datasets/schemas.py 96.61% <0.00%> (ø)
superset/utils/feature_flag_manager.py 96.29% <0.00%> (ø)
superset/dashboards/commands/importers/v1/utils.py 81.42% <0.00%> (ø)
superset/dashboards/schemas.py 99.41% <0.00%> (+<0.01%) ⬆️
superset/charts/schemas.py 99.34% <0.00%> (+<0.01%) ⬆️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ae83fa...f0ebed9. Read the comment docs.

@eschutho
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

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

Copy link
Member

@lyndsiWilliams lyndsiWilliams left a comment

Choose a reason for hiding this comment

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

I'm not super familiar with this section of the code, but from what I see this looks good to me. Nice fix with good tests to check if it happens again. I tried to test this in the test env but I don't seem to have access to the template params here (see screenshot). This could be something I'm missing in my local setup, so if I can do something to be able to test this I'd be happy to run through it 😁
Screen Shot 2021-12-17 at 6 44 11 AM

@@ -2395,7 +2395,7 @@ def validate_sql_json(
schema = request.form.get("schema") or None
template_params = json.loads(request.form.get("templateParams") or "{}")

if len(template_params) > 0:
if template_params is not None and len(template_params) > 0:
Copy link
Member

Choose a reason for hiding this comment

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

Nit, since in Python an empty list/dict is false you can simplify to:

Suggested change
if template_params is not None and len(template_params) > 0:
if template_params:

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks! Sorry, I just saw this note after I merged. I can clean it up separately.

@lyndsiWilliams
Copy link
Member

/testenv up FEATURE_ALERT_REPORTS=true

@github-actions
Copy link
Contributor

@lyndsiWilliams Ephemeral environment creation is currently limited to committers.

@github-actions
Copy link
Contributor

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

@AAfghahi
Copy link
Member

/testenv up FEATURE_ENABLE_TEMPLATE_PROCESSING=True

@github-actions
Copy link
Contributor

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

@lyndsiWilliams
Copy link
Member

Thanks for the help with the test env! Everything works as described, I am more confident in my approval 👍

@eschutho eschutho merged commit b82da5c into apache:master Dec 17, 2021
@eschutho eschutho deleted the elizabeth/fix-validator-params branch December 17, 2021 18:52
shcoderAlex pushed a commit to casual-precision/superset that referenced this pull request Feb 7, 2022
bwang221 pushed a commit to casual-precision/superset that referenced this pull request Feb 10, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 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:2021.49 preset-io size/M 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants