bito-code-review[bot] commented on code in PR #44581:
URL: https://github.com/apache/superset/pull/44581#discussion_r4112948712
##########
superset/mcp_service/middleware.py:
##########
@@ -218,6 +221,16 @@ def _invoke_error_hook(error: Exception, hook_context:
dict[str, Any]) -> None:
logger.warning("MCP_ERROR_HOOK raised an exception: %s", hook_error)
+async def _invoke_error_hook_off_loop(
+ error: Exception, hook_context: dict[str, Any]
+) -> None:
+ """Keep hook I/O and context-setup failures outside the error boundary."""
+ try:
+ await run_in_metadata_thread(_invoke_error_hook, error, hook_context)
+ except Exception as hook_error: # noqa: BLE001
+ logger.warning("Could not run MCP_ERROR_HOOK: %s", hook_error)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Error hook DB dependency</b></div>
<div id="fix">
`_invoke_error_hook` only reads `MCP_ERROR_HOOK` config via
`get_flask_app()`; it never touches the metadata session. Routing it through
`run_in_metadata_thread` adds a DB dependency — `execute()` reloads `g.user`
via `db.session.get` (worker.py) — so during a metadata outage the hook is
silently skipped (caught at line 230), and every tool error pays a needless
user-reload query even when no hook is configured.
</div>
</div>
<small><i>Code Review Run #8985f4</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]