bito-code-review[bot] commented on PR #43763:
URL: https://github.com/apache/superset/pull/43763#issuecomment-5495067662
<!-- Bito Reply -->
The issue is that the `EXTRA_ASSET_IMPORT_HANDLER` is invoked after the
asset is created but outside the main import transaction, meaning any side
effects it performs are not rolled back if the transaction subsequently fails.
To resolve this, the handler should be invoked within the transaction scope, or
its side effects should be managed to ensure atomicity.
Since the handler is intended to be a flexible hook, the most robust
approach is to ensure the import command itself handles the transaction
boundary correctly. In `superset/commands/chart/importers/v1/utils.py` and
`superset/commands/dashboard/importers/v1/utils.py`, the
`apply_extra_import_fields` call should be moved inside the `try...except`
block that manages the database session, or the handler should be designed to
be idempotent.
Would you like me to check the other comments on this PR to see if there are
more issues to address?
**superset/commands/chart/importers/v1/utils.py**
```
# ... existing code ...
chart = Slice.import_from_dict(config, recursive=False,
allow_reparenting=True)
if chart.id is None:
db.session.flush()
apply_extra_import_fields(chart, "chart", extra)
return chart
```
--
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]