superset icon indicating copy to clipboard operation
superset copied to clipboard

fix: Validate required fields in sql_json API

Open EugeneTorap opened this issue 3 years ago • 1 comments

fix #20873 issues.

SUMMARY

sql_json API has two required fields:

  • sql: string
  • database_id: integer

We need to validate these fields if they are None and send user an understandable error if one of the fields is missing.

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

EugeneTorap avatar Aug 07 '22 13:08 EugeneTorap

Codecov Report

Merging #21003 (e09b951) into master (e214e1a) will decrease coverage by 0.15%. The diff coverage is 73.20%.

:exclamation: Current head e09b951 differs from pull request most recent head 41735bf. Consider uploading reports for the commit 41735bf to get more accurate results

@@            Coverage Diff             @@
##           master   #21003      +/-   ##
==========================================
- Coverage   66.34%   66.18%   -0.16%     
==========================================
  Files        1767     1768       +1     
  Lines       67312    67367      +55     
  Branches     7144     7144              
==========================================
- Hits        44656    44586      -70     
- Misses      20828    20953     +125     
  Partials     1828     1828              
Flag Coverage Δ
hive ?
mysql 80.95% <93.93%> (+0.02%) :arrow_up:
postgres 81.00% <93.93%> (+0.01%) :arrow_up:
presto ?
python 81.12% <93.93%> (-0.36%) :arrow_down:
sqlite 79.61% <93.93%> (+0.02%) :arrow_up:
unit ?

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

Impacted Files Coverage Δ
...packages/superset-ui-core/src/query/types/Query.ts 100.00% <ø> (ø)
...ackages/superset-ui-core/src/utils/featureFlags.ts 100.00% <ø> (ø)
...rts/src/BigNumber/BigNumberTotal/transformProps.ts 0.00% <0.00%> (ø)
...lugin-chart-echarts/src/BigNumber/BigNumberViz.tsx 0.00% <0.00%> (ø)
...lugin-chart-echarts/src/BoxPlot/EchartsBoxPlot.tsx 0.00% <0.00%> (ø)
.../plugins/plugin-chart-echarts/src/BoxPlot/types.ts 0.00% <ø> (ø)
.../plugin-chart-echarts/src/Funnel/EchartsFunnel.tsx 0.00% <0.00%> (ø)
...d/plugins/plugin-chart-echarts/src/Funnel/types.ts 100.00% <ø> (ø)
...ns/plugin-chart-echarts/src/Gauge/EchartsGauge.tsx 0.00% <0.00%> (ø)
...ns/plugin-chart-echarts/src/Graph/EchartsGraph.tsx 0.00% <0.00%> (ø)
... and 96 more

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

codecov[bot] avatar Aug 07 '22 13:08 codecov[bot]

@hughhhh @betodealmeida Can you review it?

EugeneTorap avatar Aug 08 '22 20:08 EugeneTorap

Hi @EugeneTorap, Thanks for adding validation on the endpoint. Do you mind following the Mashmallow validation schema for the requesting validation? Here are some examples.

zhaoyongjie avatar Aug 09 '22 13:08 zhaoyongjie

Hi @EugeneTorap, Thanks for adding validation on the endpoint. Do you mind following the Mashmallow validation schema for the requesting validation? Here are some examples.

Thanks, will do it

EugeneTorap avatar Aug 09 '22 13:08 EugeneTorap