codeant-ai-for-open-source[bot] commented on code in PR #42851:
URL: https://github.com/apache/superset/pull/42851#discussion_r3730641105
##########
superset/sql/execution/executor.py:
##########
@@ -751,14 +753,18 @@ def _render_sql_template(
:param sql: SQL string potentially containing Jinja2 templates
:param template_params: Parameters to pass to the template
:returns: Rendered SQL string
+ :raises SupersetTemplateException: if the template fails to render
"""
if template_params is None:
return sql
from superset.jinja_context import get_template_processor
tp = get_template_processor(database=self.database)
- return tp.process_template(sql, **template_params)
+ try:
+ return tp.process_template(sql, **template_params)
+ except TemplateError as ex:
+ raise SupersetTemplateException(str(ex)) from ex
Review Comment:
**Suggestion:** The broad `TemplateError` catch flattens compilation-time
`TemplateSyntaxError` exceptions raised by direct-rendering processors such as
Spark and Trino into a generic `SupersetTemplateException`, discarding the
structured `SupersetSyntaxErrorException`/`SupersetError` details that the
standard processor provides. Preserve the existing typed syntax-error mapping
before applying the fallback wrapper for raw render-time errors. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Spark and Trino template syntax errors lose line metadata.
- ⚠️ API responses lose structured syntax-error classification.
- ⚠️ SQL Lab users receive less actionable template diagnostics.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=214effed2c914800ba41c9cdc5f94219&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=214effed2c914800ba41c9cdc5f94219&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/sql/execution/executor.py
**Line:** 764:767
**Comment:**
*Api Mismatch: The broad `TemplateError` catch flattens
compilation-time `TemplateSyntaxError` exceptions raised by direct-rendering
processors such as Spark and Trino into a generic `SupersetTemplateException`,
discarding the structured `SupersetSyntaxErrorException`/`SupersetError`
details that the standard processor provides. Preserve the existing typed
syntax-error mapping before applying the fallback wrapper for raw render-time
errors.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42851&comment_hash=bcaa85b67a98499f672e3ba340882c35a7f247581fdf3f5917572e297def7c38&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42851&comment_hash=bcaa85b67a98499f672e3ba340882c35a7f247581fdf3f5917572e297def7c38&reaction=dislike'>👎</a>
--
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]