mirror of
https://github.com/apache/superset.git
synced 2026-05-24 17:25:20 +00:00
fix(sqllab): keep saved-query list working when Jinja dataset(id) references a deleted dataset
When a saved query contains a Jinja macro such as `{{ dataset(id) }}` and the
referenced dataset is later deleted, `process_jinja_sql` raises
`DatasetNotFoundError` while computing the `sql_tables` field. That exception
was not caught by `SqlTablesMixin.sql_tables`, so the entire saved-query list
endpoint failed with "Dataset ID not found", hiding every saved query from
the user and preventing them from deleting the broken one (#32771).
Treat any `SupersetException` raised during table extraction the same way as
existing parse/security/template errors: log a warning and return an empty
list so the rest of the row can still be serialized.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -21,8 +21,13 @@ from flask_appbuilder import Model
|
||||
from jinja2.exceptions import TemplateError
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from superset.commands.dataset.exceptions import DatasetNotFoundError
|
||||
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
||||
from superset.exceptions import SupersetParseError, SupersetSecurityException
|
||||
from superset.exceptions import (
|
||||
SupersetParseError,
|
||||
SupersetSecurityException,
|
||||
SupersetTemplateException,
|
||||
)
|
||||
from superset.models.sql_lab import Query, SavedQuery
|
||||
|
||||
|
||||
@@ -48,6 +53,11 @@ from superset.models.sql_lab import Query, SavedQuery
|
||||
message="Invalid SQL syntax",
|
||||
),
|
||||
TemplateError,
|
||||
# ``{{ dataset(id) }}`` referencing a deleted dataset previously
|
||||
# bubbled up through ``sql_tables`` and broke saved-query list
|
||||
# endpoints (see issue #32771).
|
||||
DatasetNotFoundError("Dataset 1 not found!"),
|
||||
SupersetTemplateException("Template rendering failed"),
|
||||
],
|
||||
)
|
||||
def test_sql_tables_mixin_sql_tables_exception(
|
||||
|
||||
Reference in New Issue
Block a user