{"record":{"id":"0afb2b82d82840e5","repo":"apache/superset","slug":"cannot-modify-system-themes-0afb2b","errorCode":null,"errorMessage":"Cannot modify system themes.","messagePattern":"Cannot modify system themes\\.","errorType":"exception","errorClass":"SystemThemeProtectedError","httpStatus":500,"severity":"error","filePath":"superset/commands/theme/update.py","lineNumber":54,"sourceCode":"        self._properties = data.copy()\n        self._model: Optional[Theme] = None\n\n    @transaction(on_error=partial(on_error, reraise=Exception))\n    def run(self) -> Theme:\n        self.validate()\n        assert self._model\n        theme = ThemeDAO.update(self._model, self._properties)\n        return theme\n\n    def validate(self) -> None:\n        # Validate theme exists\n        self._model = ThemeDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise ThemeNotFoundError()\n\n        # Check if it's a system theme\n        if self._model.is_system:\n            raise SystemThemeProtectedError()\n","sourceCodeStart":36,"sourceCodeEnd":55,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/theme/update.py#L36-L55","documentation":"Raised by UpdateThemeCommand.validate() when the target theme has is_system=True. System themes are protected built-ins; the guard fires before ThemeDAO.update, so system theme configuration is immutable through the normal update command.","triggerScenarios":"PATCHing a built-in/system theme record (one flagged is_system in the theme table) with modified properties.","commonSituations":"Attempting to customize a shipped theme instead of duplicating it; admin tooling that iterates all themes and updates them indiscriminately; misunderstanding that system themes must be cloned, not edited.","solutions":["Duplicate the system theme into a new user-owned theme and edit the copy.","If you truly must change a system theme, do it through whatever import/seed mechanism owns system records, not the update API.","Filter is_system themes out of editable lists in admin UIs."],"exampleFix":"# before\nUpdateThemeCommand(model_id=system_theme.id, properties={\"theme\": cfg}).run()\n\n# after\nclone = ThemeDAO.create({\"theme_name\": f\"{system_theme.theme_name} copy\", \"theme\": cfg, ...})\nUpdateThemeCommand(model_id=clone.id, properties={\"theme\": cfg}).run()","handlingStrategy":"validation","validationCode":"theme = ThemeDAO.find_by_id(model_id)\nif theme and theme.is_system:\n    raise PermissionError(\"clone the system theme instead of editing it\")","typeGuard":null,"tryCatchPattern":"from superset.commands.theme.exceptions import SystemThemeProtectedError\ntry:\n    UpdateThemeCommand(model_id, props).run()\nexcept SystemThemeProtectedError:\n    clone_then_update(model_id, props)","preventionTips":["Hide is_system themes from editable UI lists","Always clone-then-edit system themes"],"tags":["theme","protected","validation","backend"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}