{"record":{"id":"1cfc72e8cae81979","repo":"invoke-ai/InvokeAI","slug":"administrator-account-already-configured","errorCode":null,"errorMessage":"Administrator account already configured","messagePattern":"Administrator account already configured","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"invokeai/app/api/routers/auth.py","lineNumber":384,"sourceCode":"\n    Raises:\n        HTTPException: 400 if admin already exists or password is weak\n        HTTPException: 403 if multiuser mode is disabled\n    \"\"\"\n    config = ApiDependencies.invoker.services.configuration\n\n    # Check if multiuser is enabled\n    if not config.multiuser:\n        raise HTTPException(\n            status_code=status.HTTP_403_FORBIDDEN,\n            detail=\"Multiuser mode is disabled. Admin setup is not required in single-user mode.\",\n        )\n\n    user_service = ApiDependencies.invoker.services.users\n\n    # Check if any admin exists\n    if user_service.has_admin():\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Administrator account already configured\",\n        )\n\n    # Create admin user - this will validate password strength\n    try:\n        user_data = UserCreateRequest(\n            email=request.email,\n            display_name=request.display_name,\n            password=request.password,\n            is_admin=True,\n        )\n        user = user_service.create_admin(user_data, strict_password_checking=config.strict_password_checking)\n    except ValueError as e:\n        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) from e\n\n    return SetupResponse(success=True, user=user)\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/auth.py#L366-L402","documentation":"HTTP 400 raised by the POST /auth/setup endpoint in invokeai/app/api/routers/auth.py:384. InvokeAI allows exactly one administrator account, created through the one-time setup flow. If `user_service.has_admin()` reports an existing admin, the setup endpoint refuses to create another one with this detail message.","triggerScenarios":"Calling POST /api/v1/auth/setup (setup_admin) when the database already contains an active user with is_admin=true — i.e. after setup has already been completed.","commonSituations":"Re-running the setup wizard after the admin was already created; a second browser tab or CI script racing to call setup; restoring a database that already has an admin and then re-running setup; forgetting the admin password and trying to create a new admin via setup instead of using the password reset.","solutions":["Skip the setup call — log in with the existing admin account instead.","If the admin password is lost, use the existing password-reset flow rather than re-running setup.","If the existing admin row is stale/corrupt, remove or demote it via the user-management endpoints (PATCH/DELETE /users/{id}) so has_admin() returns false, then re-run setup.","As a last resort on a dev instance, delete/reset the users table (or the SQLite db file invokeai.db) and re-run setup.","Guard client code: check setup status (GET setup endpoint) before POSTing."],"exampleFix":"// before: blind setup call on an already-initialized instance\nawait fetch('/api/v1/auth/setup', {method:'POST', body: JSON.stringify(payload)});\n// after: only setup when no admin exists yet\nconst status = await (await fetch('/api/v1/auth/setup')).json();\nif (status.needs_setup /* no admin */) {\n  await fetch('/api/v1/auth/setup', {method:'POST', body: JSON.stringify(payload)});\n}","handlingStrategy":"validation","validationCode":"// Only attempt setup when no admin exists\nconst probe = await fetch('/api/v1/auth/setup');\nconst info = await probe.json();\nif (!info.needs_setup) return; // admin already configured\nawait fetch('/api/v1/auth/setup', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(payload)});","typeGuard":null,"tryCatchPattern":"try {\n  await setupAdmin(payload);\n} catch (e) {\n  if (e.status === 400 && e.detail === 'Administrator account already configured') {\n    // setup already done — proceed to login\n  } else throw e;\n}","preventionTips":["Check setup status before POSTing to /auth/setup","Run setup exactly once, from a single place (one bootstrap script, not every deploy)","Never use setup as a password-reset mechanism","Track 'instance initialized' state in your deploy tooling"],"tags":["http-400","auth","setup","fastapi"],"backgroundTag":"admin-already-configured","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}