apache/superset · error · ThemeNotFoundError

Theme not found.

Error message

Theme not found.

What it means

Raised by UpdateThemeCommand.validate() when the theme to update cannot be found by ID. The update command resolves the model first; a missing row raises ThemeNotFoundError before any property merge happens, so no partial update can occur.

Source

Thrown at superset/commands/theme/update.py:50

class UpdateThemeCommand(UpdateMixin):
    def __init__(self, model_id: int, data: dict[str, Any]):
        self._model_id = model_id
        self._properties = data.copy()
        self._model: Optional[Theme] = None

    @transaction(on_error=partial(on_error, reraise=Exception))
    def run(self) -> Theme:
        self.validate()
        assert self._model
        theme = ThemeDAO.update(self._model, self._properties)
        return theme

    def validate(self) -> None:
        # Validate theme exists
        self._model = ThemeDAO.find_by_id(self._model_id)
        if not self._model:
            raise ThemeNotFoundError()

        # Check if it's a system theme
        if self._model.is_system:
            raise SystemThemeProtectedError()

View on GitHub (pinned to f4587218dd)

Solutions

  1. Re-fetch the theme list and confirm the target ID still exists before PATCHing.
  2. Handle 404 in the client by reloading the theme collection and discarding stale edits.
  3. If IDs are unstable in your setup, migrate theme references to stable identifiers.

Example fix

# before
UpdateThemeCommand(model_id=42, properties={...}).run()

# after
if ThemeDAO.find_by_id(42) is None:
    raise LookupError("theme 42 deleted; reload themes")
UpdateThemeCommand(model_id=42, properties={...}).run()
Defensive patterns

Strategy: validation

Validate before calling

if ThemeDAO.find_by_id(model_id) is None:
    raise LookupError("theme deleted; reload")

Try / catch

try:
    UpdateThemeCommand(model_id, properties).run()
except ThemeNotFoundError:
    discard_stale_edits_and_reload()

Prevention

When it happens

Trigger: PUT/PATCH on /api/v1/theme/<id> with an ID that was deleted; two editors where one deleted the theme the other is still editing; passing a wrong type of ID (e.g. UUID string where an integer PK is expected).

Common situations: Editing a theme in a long-open browser tab after the theme was removed elsewhere; API integrations holding cached IDs; DB rows cleared between environments.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/6f8c93fd940c4371. Report an issue: GitHub.