bito-code-review[bot] commented on PR #43261:
URL: https://github.com/apache/superset/pull/43261#issuecomment-5317919882
<!-- Bito Reply -->
The reviewer's suggestion is correct. While the current implementation
catches `json.JSONDecodeError` for malformed JSON strings, it does not handle
cases where `masked_encrypted_extra` is a non-string type (like a list or
mapping), which causes `json.loads()` to raise a `TypeError`.
To resolve this, you should catch `TypeError` alongside
`json.JSONDecodeError` in the `try-except` block in
`superset/commands/importers/v1/utils.py`.
```python
except (json.JSONDecodeError, TypeError) as exc:
# masked_encrypted_extra comes straight from the imported
YAML
# (before schema validation) and may not be valid JSON.
logger.error(
"Invalid JSON in masked_encrypted_extra for %s: %s",
file_name,
exc,
)
exceptions.append(
ValidationError({file_name: {"masked_encrypted_extra":
[str(exc)]}})
)
```
I have checked the available PR comments, and there are no other pending
review comments to address. Would you like me to proceed with any other tasks?
**superset/commands/importers/v1/utils.py**
```
except (json.JSONDecodeError, TypeError) as exc:
# masked_encrypted_extra comes straight from the imported
YAML
# (before schema validation) and may not be valid JSON.
logger.error(
"Invalid JSON in masked_encrypted_extra for %s: %s",
file_name,
exc,
)
exceptions.append(
ValidationError({file_name: {"masked_encrypted_extra":
[str(exc)]}})
)
```
--
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]