codeant-ai-for-open-source[bot] commented on code in PR #42366:
URL: https://github.com/apache/superset/pull/42366#discussion_r3692374122
##########
superset/models/helpers.py:
##########
@@ -2775,6 +2775,16 @@ def get_rendered_sql(
if template_processor:
try:
sql = template_processor.process_template(sql)
+ except UndefinedError as ex:
+ # Raised when a template references an undefined value, e.g.
+ # indexing into an empty list returned by `filter_values()`
+ # when no dashboard filter is active for that column.
+ raise QueryObjectValidationError(
+ _(
+ "Virtual dataset template error: %(msg)s",
+ msg=str(ex),
+ )
+ ) from ex
Review Comment:
**Suggestion:** The new handling only applies when rendering through
`get_rendered_sql()`. Virtual dataset metadata discovery renders the same SQL
directly via `get_virtual_table_metadata()` and catches only
`SupersetSyntaxErrorException`, so an empty `filter_values('col')[0]` still
escapes as an unhandled `UndefinedError` on metadata-related endpoints. Move
this translation into shared template-processing handling or add equivalent
handling to the metadata path so both virtual-dataset workflows return the
intended validation error. [incomplete implementation]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Virtual-dataset metadata endpoint can return an unhandled server error.
- ⚠️ Dataset column discovery fails for unset template filters.
- ⚠️ Metadata refresh also calls `external_metadata()` at `models.py:1978`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=396fe04ee51e46babd64cfa77d77318b&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=396fe04ee51e46babd64cfa77d77318b&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/models/helpers.py
**Line:** 2778:2787
**Comment:**
*Incomplete Implementation: The new handling only applies when
rendering through `get_rendered_sql()`. Virtual dataset metadata discovery
renders the same SQL directly via `get_virtual_table_metadata()` and catches
only `SupersetSyntaxErrorException`, so an empty `filter_values('col')[0]`
still escapes as an unhandled `UndefinedError` on metadata-related endpoints.
Move this translation into shared template-processing handling or add
equivalent handling to the metadata path so both virtual-dataset workflows
return the intended validation error.
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%2F42366&comment_hash=f011b552d92becc2b64eab9bf3eb02e53d4d97cea84f2fe6d8ee1e8b2c46c546&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42366&comment_hash=f011b552d92becc2b64eab9bf3eb02e53d4d97cea84f2fe6d8ee1e8b2c46c546&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]