{"record":{"id":"a30e786879e798e7","repo":"apache/superset","slug":"user-not-found","errorCode":null,"errorMessage":"User not found.","messagePattern":"User not found\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"superset/commands/security/reset.py","lineNumber":54,"sourceCode":"        confirm: bool,\n        user: Any,\n        exclude_users: Optional[str] = None,\n        exclude_roles: Optional[str] = None,\n    ) -> None:\n        self._user = user\n        self._confirm = confirm\n        self._users_to_exclude = [\"admin\"]\n        if exclude_users:\n            self._users_to_exclude.extend(exclude_users.split(\",\"))\n        self._roles_to_exclude = [\"Admin\", \"Public\", \"Gamma\", \"Alpha\", \"sql_lab\"]\n        if exclude_roles:\n            self._roles_to_exclude.extend(exclude_roles.split(\",\"))\n\n    def validate(self) -> None:\n        if not self._confirm:\n            raise Exception(\"Reset aborted.\")  # pylint: disable=broad-exception-raised\n        if not self._user or not self._user.is_active:\n            raise Exception(\"User not found.\")  # pylint: disable=broad-exception-raised\n\n    def run(self) -> None:\n        self.validate()\n        logger.debug(\"Resetting Superset Started\")\n        db.session.query(SqlaTable).delete()\n        databases = db.session.query(Database)\n        for database in databases:\n            db.session.delete(database)\n        db.session.query(Dashboard).delete()\n        db.session.query(Slice).delete()\n        db.session.query(KeyValueEntry).delete()\n        db.session.query(Log).delete()\n        db.session.query(FavStar).delete()\n\n        logger.debug(\"Ignoring Users: %s\", self._users_to_exclude)\n        users_to_delete = (\n            db.session.query(security_manager.user_model)\n            .filter(security_manager.user_model.username.not_in(self._users_to_exclude))","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/security/reset.py#L36-L72","documentation":"Exception('User not found.') is raised by SecurityResetCommand.validate when the acting user is None or is_active is false — the reset only runs for a present, active user, checked after the confirm gate.","triggerScenarios":"Running the security reset where the resolved user is anonymous/None (unauthenticated context) or the account has been deactivated; passing a username that resolves to a disabled user.","commonSituations":"Invoking reset from a scheduler/Celery context without a user; the 'admin' account deactivated before someone attempted the reset; user record disabled during offboarding while automation still ran.","solutions":["Run the reset as an existing active user (typically the admin account)","Re-activate the target user first (update is_active=true) if it must perform the reset","Pass the correct authenticated user object/username to the command"],"exampleFix":"# before\nSecurityResetCommand(user=None, confirm=True).run()\n\n# after\nadmin = sm.find_user('admin')\nassert admin and admin.is_active\nSecurityResetCommand(user=admin, confirm=True).run()","handlingStrategy":"validation","validationCode":"assert user is not None and user.is_active, 'reset needs an active user'","typeGuard":"def user_can_run_reset(user) -> bool:\n    return user is not None and bool(user.is_active)","tryCatchPattern":null,"preventionTips":["Pass the resolved authenticated user explicitly, not None","Re-activate or recreate the admin account before running resets","Smoke-check user.is_active in automation preflight"],"tags":["cli","security-reset","user-state","validation"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}