-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: catch error when masking encrypted extra is none #21570
fix: catch error when masking encrypted extra is none #21570
Conversation
superset/db_engine_specs/bigquery.py
Outdated
try: | ||
config = json.loads(encrypted_extra) | ||
except json.JSONDecodeError: | ||
config = json.loads(encrypted_extra) # type:ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@betodealmeida the other option here would be to have a default value if encrypted_extra is None, but I opted for including it in the try/catch since it already existed. Of course, this requires the type ignores because the linter isn't aware of the try/except.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Alternatively I think this would also work:
def mask_encrypted_extra(cls, encrypted_extra: Optional[str]) -> Optional[str]:
if encrypted_extra is None:
return encrypted_extra
try:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Yeah I think it looks better this way without the type ignores. I also left the TypeError in the except block just in case.
Codecov Report
@@ Coverage Diff @@
## master #21570 +/- ##
===========================================
- Coverage 66.67% 55.30% -11.38%
===========================================
Files 1793 1794 +1
Lines 68523 68642 +119
Branches 7281 7281
===========================================
- Hits 45688 37960 -7728
- Misses 20971 28818 +7847
Partials 1864 1864
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
64ad21b
to
978232b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few code smell nits
bd8010d
to
a3e063b
Compare
a3e063b
to
7ac5ca0
Compare
/testenv up |
@yousoph Ephemeral environment spinning up at http://35.91.149.182:8080. Credentials are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching and fixing this!
superset/db_engine_specs/bigquery.py
Outdated
try: | ||
config = json.loads(encrypted_extra) | ||
except json.JSONDecodeError: | ||
config = json.loads(encrypted_extra) # type:ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Alternatively I think this would also work:
def mask_encrypted_extra(cls, encrypted_extra: Optional[str]) -> Optional[str]:
if encrypted_extra is None:
return encrypted_extra
try:
...
f0556ce
to
ad122fc
Compare
Ephemeral environment shutdown and build artifacts deleted. |
(cherry picked from commit ef78ec6)
SUMMARY
When masking/unmasking the encrypted extra field, this change allows imported dbs to have a blank encrypted extra field, because they are not imported.
TESTING INSTRUCTIONS
Import a database and try to edit it in the database connection modal.
ADDITIONAL INFORMATION