bito-code-review[bot] commented on PR #43772:
URL: https://github.com/apache/superset/pull/43772#issuecomment-5497376120
<!-- Bito Reply -->
The flagged issue is correct. While the current change handles
`JSONDecodeError` for strings, it does not validate that the parsed JSON is a
dictionary, which is expected by the credentials adapter. If `json.loads`
returns a scalar (like a string or number) or a list, the subsequent code may
fail.
To resolve this, you should add a type check after parsing the JSON:
```python
if isinstance(encrypted_credentials, str):
try:
encrypted_credentials = json.loads(encrypted_credentials)
if not isinstance(encrypted_credentials, dict):
raise ValueError("Credentials must be a JSON object")
except (json.JSONDecodeError, ValueError):
# ... existing error handling ...
```
There are no other comments on this PR to address.
**superset/db_engine_specs/gsheets.py**
```
encrypted_credentials = json.loads(encrypted_credentials)
if not isinstance(encrypted_credentials, dict):
raise ValueError("Credentials must be a JSON object")
except (json.JSONDecodeError, ValueError):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]