apache/superset · warning · CssTemplateNotFoundError
CSS template not found.
Error message
CSS template not found.
What it means
CssTemplateNotFoundError is raised by CssTemplateDeleteCommand.validate() when CssTemplateDAO.find_by_ids() returns no rows, or returns fewer rows than the number of requested ids. It signals that one or more CSS template ids in the delete request do not exist in the metadata database.
Source
Thrown at superset/commands/css/delete.py:48
logger = logging.getLogger(__name__)
class DeleteCssTemplateCommand(BaseCommand):
def __init__(self, model_ids: list[int]):
self._model_ids = model_ids
self._models: Optional[list[CssTemplate]] = None
@transaction(on_error=partial(on_error, reraise=CssTemplateDeleteFailedError))
def run(self) -> None:
self.validate()
assert self._models
CssTemplateDAO.delete(self._models)
def validate(self) -> None:
# Validate/populate model exists
self._models = CssTemplateDAO.find_by_ids(self._model_ids)
if not self._models or len(self._models) != len(self._model_ids):
raise CssTemplateNotFoundError()
View on GitHub (pinned to f4587218dd)
Solutions
- Refresh the CSS template list (GET /api/v1/css_template/) and retry the delete with only ids that still exist.
- Make the delete flow idempotent in the client: treat a 404 CssTemplateNotFoundError as success when the goal is removal.
- Check for concurrent deletion: confirm no other admin/session removed the templates before issuing the bulk delete.
Example fix
# before CssTemplateDeleteCommand([1, 2, 99]).run() # 99 no longer exists # after existing = CssTemplateDAO.find_by_ids([1, 2, 99]) CssTemplateDeleteCommand([t.id for t in existing]).run()
Defensive patterns
Strategy: validation
Validate before calling
from superset.daos.css_templates import CssTemplateDAO
ids = [1, 2, 99]
existing = CssTemplateDAO.find_by_ids(ids)
if len(existing) != len(ids):
missing = set(ids) - {t.id for t in existing}
logger.info('skipping already-deleted css templates: %s', missing)
ids_to_delete = [t.id for t in existing] Try / catch
try:
CssTemplateDeleteCommand(ids).run()
except CssTemplateNotFoundError:
# idempotent delete: target state already reached
pass Prevention
- Refresh id lists from the API immediately before bulk deletes.
- Make UI delete buttons idempotent for 404 responses.
- Avoid hardcoded CSS template ids in scripts.
When it happens
Trigger: Calling DELETE /api/v1/css_template/ with a list of ids where at least one id is missing, already deleted, or a client-side stale id from a previous session. Also triggered when a concurrent request deletes the same template between the client's fetch and delete.
Common situations: UI grid with multi-select where a template was deleted by another user in another tab; scripts deleting by hardcoded ids after a DB reset; double-click on the delete button causing the second request to 404.
Related errors
- Chart not found.
- Dashboard not found.
- Database not found.
- Dataset metric not found.
- Report Schedule not found.
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/3b849cc354dfd45a.
Report an issue: GitHub.