bito-code-review[bot] commented on code in PR #34880:
URL: https://github.com/apache/superset/pull/34880#discussion_r3012581697
##########
superset/commands/dashboard/importers/v1/__init__.py:
##########
@@ -67,6 +68,31 @@ class ImportDashboardsCommand(ImportModelsCommand):
}
import_error = DashboardImportError
+ def __init__(self, contents: dict[str, str], *args: Any, **kwargs: Any) ->
None:
+ self.overwrite_all = kwargs.pop("overwrite_all", False)
+ super().__init__(contents, *args, **kwargs)
+
+ # not sure if overriding run is the best approach here
+ # it works fine and is better than a global variable imo
+ # open to suggestions
+ def run(self) -> None:
+ self.validate()
+
+ try:
+ self._import(
+ self._configs,
+ self.overwrite,
+ self.contents,
+ overwrite_all=self.overwrite_all,
+ )
+ db.session.commit()
+ except CommandException:
+ db.session.rollback()
+ raise
+ except Exception as ex:
+ db.session.rollback()
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Inconsistent Exception Handling</b></div>
<div id="fix">
The overridden run method rolls back the session on CommandException, but
the parent ImportModelsCommand does not, treating CommandException as a
non-rollback exception (e.g., for validation errors). This inconsistency may
cause partial DB changes to be incorrectly undone. To match parent behavior,
remove the rollback on CommandException.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
````
</div>
</details>
</div>
<small><i>Code Review Run #b7ab40</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]