bito-code-review[bot] commented on PR #40008:
URL: https://github.com/apache/superset/pull/40008#issuecomment-4417540581
<!-- Bito Reply -->
The flagged issue is valid: the code at lines 149-158 in utils.py can raise
a KeyError when datasetUuid is not in dataset_info, leading to unhandled
crashes instead of controlled errors. To resolve, guard the lookup by checking
if the UUID exists before accessing, and raise ImportFailedError with context
for missing mappings. Here's the concise fix applied to the relevant block.
There are no other comments in this PR, so no additional fixes are needed.
**superset/commands/dashboard/importers/v1/utils.py**
```
# fix display control dataset references
chart_customization_config = fixed.get("metadata", {}).get(
"chart_customization_config", []
)
for customization in chart_customization_config:
targets = customization.get("targets", [])
for target in targets:
dataset_uuid = target.pop("datasetUuid", None)
if dataset_uuid:
if dataset_uuid in dataset_info:
target["datasetId"] =
dataset_info[dataset_uuid]["datasource_id"]
else:
raise ImportFailedError(f"Dataset UUID {dataset_uuid}
not found in imported datasets")
```
--
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]