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: validate DB-specific parameters #15155

Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

The validate_parameters endpoint was not performing the DB-specific Marshmallow validation (based on parameters_schema), but only the validation from the validate_parameters schema in the DB engine spec (which does more deep validation like checking if the host is resolvable and the port is open, but doesn't validate the schema).

I changed the DatabaseValidateParametersSchema schema validation to also validate the DB-specific parameters, and changed the API to return the error messages expected by the frontend for the onBlur validation (with an invalid key in the extra).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added unit tests.

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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 Jun 14, 2021

Codecov Report

Merging #15155 (7ebf57c) into master (cc2b4fe) will decrease coverage by 0.00%.
The diff coverage is 96.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15155      +/-   ##
==========================================
- Coverage   77.54%   77.53%   -0.01%     
==========================================
  Files         967      967              
  Lines       49752    49783      +31     
  Branches     6351     6351              
==========================================
+ Hits        38578    38598      +20     
- Misses      10972    10983      +11     
  Partials      202      202              
Flag Coverage Δ
hive 81.42% <96.00%> (-0.02%) ⬇️
mysql 81.70% <96.00%> (-0.03%) ⬇️
postgres 81.71% <96.00%> (-0.03%) ⬇️
python 82.09% <96.00%> (-0.03%) ⬇️
sqlite 81.35% <96.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
superset/db_engine_specs/bigquery.py 89.62% <75.00%> (-0.53%) ⬇️
superset/databases/api.py 93.18% <100.00%> (+0.14%) ⬆️
superset/databases/schemas.py 98.76% <100.00%> (+0.03%) ⬆️
superset/exceptions.py 93.50% <0.00%> (-5.20%) ⬇️
superset/databases/commands/create.py 88.23% <0.00%> (-3.93%) ⬇️
superset/queries/saved_queries/api.py 95.23% <0.00%> (-0.81%) ⬇️
superset/datasets/api.py 91.89% <0.00%> (-0.31%) ⬇️
superset/dashboards/api.py 92.95% <0.00%> (-0.26%) ⬇️
superset/charts/api.py 86.44% <0.00%> (-0.14%) ⬇️
superset/config.py 91.15% <0.00%> (ø)
... and 1 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 cc2b4fe...7ebf57c. Read the comment docs.

superset/databases/api.py Outdated Show resolved Hide resolved
assert rv.status_code == 200
assert response == {"message": "OK"}

def test_validate_parameters_invalid_port(self):
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 add validation for the range of ports allowed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, Arash is adding that on a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

@betodealmeida betodealmeida merged commit 90d9097 into apache:master Jun 15, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* fix: validate DB-specific parameters

* Fix lint

* Update test

* Fix lint/test

* Fix lint

* Update superset/databases/api.py
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* fix: validate DB-specific parameters

* Fix lint

* Update test

* Fix lint/test

* Fix lint

* Update superset/databases/api.py
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* fix: validate DB-specific parameters

* Fix lint

* Update test

* Fix lint/test

* Fix lint

* Update superset/databases/api.py
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 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/L 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants