{"record":{"id":"f75a1089570e9a93","repo":"infiniflow/ragflow","slug":"no-active-admin-please-update-is-active-in-db-m","errorCode":null,"errorMessage":"No active admin. Please update 'is_active' in db manually.","messagePattern":"No active admin\\. Please update 'is_active' in db manually\\.","errorType":"http","errorClass":"AdminException","httpStatus":500,"severity":"critical","filePath":"admin/server/auth.py","lineNumber":105,"sourceCode":"\ndef init_default_admin():\n    # Verify that at least one active admin user exists. If not, create a default one.\n    users = UserService.query(is_superuser=True)\n    if not users:\n        default_admin = {\n            \"id\": uuid.uuid1().hex,\n            \"password\": encode_to_base64(\"admin\"),\n            \"nickname\": \"admin\",\n            \"is_superuser\": True,\n            \"email\": \"admin@ragflow.io\",\n            \"creator\": \"system\",\n            \"status\": \"1\",\n        }\n        if not UserService.save(**default_admin):\n            raise AdminException(\"Can't init admin.\", 500)\n        add_tenant_for_admin(default_admin, UserTenantRole.OWNER)\n    elif not any([u.is_active == ActiveEnum.ACTIVE.value for u in users]):\n        raise AdminException(\"No active admin. Please update 'is_active' in db manually.\", 500)\n    else:\n        default_admin_rows = [u for u in users if u.email == \"admin@ragflow.io\"]\n        if default_admin_rows:\n            default_admin = default_admin_rows[0].to_dict()\n            exist, default_admin_tenant = TenantService.get_by_id(default_admin[\"id\"])\n            if not exist:\n                add_tenant_for_admin(default_admin, UserTenantRole.OWNER)\n\n\ndef add_tenant_for_admin(user_info: dict, role: str):\n\n    tenant = {\n        \"id\": user_info[\"id\"],\n        \"name\": user_info[\"nickname\"] + \"‘s Kingdom\",\n        \"llm_id\": settings.CHAT_MDL,\n        \"embd_id\": settings.EMBEDDING_MDL,\n        \"asr_id\": settings.ASR_MDL,\n        \"parser_ids\": settings.PARSERS,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/admin/server/auth.py#L87-L123","documentation":"Raised at admin server startup (admin/server/auth.py:105) when superuser rows exist in the user table but none has is_active == ActiveEnum.ACTIVE.value. This means every admin was deactivated (e.g. blocked via the admin UI), leaving no usable administrator, so startup aborts with HTTP 500 and a message telling you to fix the flag directly in the database.","triggerScenarios":"Calling the deactivate/block admin endpoint on the only superuser, then restarting the server; or manually editing the user table and setting is_active to the INACTIVE value for all superusers. Any restart of the admin server while the condition holds re-raises this.","commonSituations":"Teams with a single admin account who disable it (status/is_active flip) to 'temporarily lock' the panel; importing a production DB snapshot where admins were soft-deleted; scripts that bulk-deactivate users without excluding superusers.","solutions":["Directly update the DB as the message instructs: UPDATE user SET is_active = 1 WHERE is_superuser = 1 (ActiveEnum.ACTIVE is typically '1').","Alternatively INSERT/restore one superuser row with is_active=1 so the 'any(...)' check passes.","Prevent recurrence: never deactivate the last active superuser; guard admin-deactivation endpoints against removing the final active admin."],"exampleFix":"-- before: no active admin, server refuses to start\nSELECT id, email, is_active FROM user WHERE is_superuser = 1;\n\n-- after: reactivate the admin in MySQL/Postgres\nUPDATE user SET is_active = '1' WHERE is_superuser = 1 AND email = 'admin@ragflow.io';","handlingStrategy":"validation","validationCode":"from api.db.services import UserService\nfrom common.constants import ActiveEnum\nactive_admins = [u for u in UserService.query(is_superuser=True) if u.is_active == ActiveEnum.ACTIVE.value]\nassert active_admins, \"no active superuser; server will refuse to start\"","typeGuard":"def has_active_superuser() -> bool:\n    users = UserService.query(is_superuser=True) or []\n    return any(u.is_active == ActiveEnum.ACTIVE.value for u in users)","tryCatchPattern":"from api.common.exceptions import AdminException\ntry:\n    start_admin_server()\nexcept AdminException as e:\n    if \"No active admin\" in str(e):\n        # UPDATE user SET is_active='1' WHERE is_superuser=1, then restart\n        raise","preventionTips":["Never deactivate the last active superuser; add a guard in user-management flows.","Keep a break-glass admin account active and documented.","Audit is_active for superusers as part of pre-restart checks."],"tags":["bootstrap","database","admin","user-management"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}