bito-code-review[bot] commented on code in PR #35009:
URL: https://github.com/apache/superset/pull/35009#discussion_r2321230331
##########
superset/jinja_context.py:
##########
@@ -698,6 +698,10 @@ def process_template(self, sql: str, **kwargs: Any) -> str:
raise SupersetTemplateException(
"Infinite recursion detected in template"
) from ex
+ except Exception as ex:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Unreliable exception handling with string
matching</b></div>
<div id="fix">
The broad `except Exception` handler with string matching on exception
messages is unreliable and can mask legitimate errors. With `DebugUndefined`
configured, undefined variables often render as template strings rather than
raising exceptions. Replace with specific `jinja2.UndefinedError` handling
after importing it.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
-from jinja2 import DebugUndefined, Environment
+from jinja2 import DebugUndefined, Environment, UndefinedError
@@ -701,4 +701,2 @@
- except Exception as ex:
- if "undefined" in str(ex).lower():
- return sql
- raise
+ except UndefinedError:
+ return sql
```
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35009#issuecomment-3252423332>#117a57</a></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]