bito-code-review[bot] commented on PR #42366:
URL: https://github.com/apache/superset/pull/42366#issuecomment-5145950832
<!-- Bito Reply -->
The flagged issue is correct. The current implementation only catches
`UndefinedError` within `get_rendered_sql()`, leaving other paths like
`get_virtual_table_metadata()` vulnerable to unhandled exceptions when template
filters are unset.
To resolve this, you should move the template processing logic into a shared
helper method that handles both `SupersetSyntaxErrorException` and
`UndefinedError`. This ensures consistent error handling across all virtual
dataset workflows.
Would you like me to fetch all other comments on this PR to validate them
and implement a minimal fix for the rest?
**superset/models/helpers.py**
```
def process_template_with_error_handling(template_processor, sql):
try:
return template_processor.process_template(sql)
except UndefinedError as ex:
raise QueryObjectValidationError(
_("Virtual dataset template error: %(msg)s", msg=str(ex))
) from ex
except SupersetSyntaxErrorException as ex:
# ... existing error handling logic ...
raise QueryObjectValidationError(str(ex)) from ex
```
--
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]