{"record":{"id":"0da4946ce9194e89","repo":"mem0ai/mem0","slug":"registration-is-closed-an-admin-account-already-e","errorCode":null,"errorMessage":"Registration is closed. An admin account already exists.","messagePattern":"Registration is closed\\. An admin account already exists\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"server/routers/auth.py","lineNumber":101,"sourceCode":"\nclass SetupStatusResponse(BaseModel):\n    needsSetup: bool\n\n\n@router.get(\"/setup-status\", response_model=SetupStatusResponse)\ndef setup_status(db: Session = Depends(get_db)):\n    count = db.scalar(select(func.count(User.id)))\n    return SetupStatusResponse(needsSetup=count == 0)\n\n\n@router.post(\"/register\", response_model=TokenResponse)\n@limiter.limit(\"5/minute\")\ndef register(request: Request, body: RegisterRequest, db: Session = Depends(get_db)):\n    \"\"\"Create the first admin account. Blocked once any user exists.\"\"\"\n    _require_password_length(body.password)\n\n    if db.scalar(select(func.count(User.id))) > 0:\n        raise HTTPException(status_code=403, detail=\"Registration is closed. An admin account already exists.\")\n\n    user = User(\n        name=body.name,\n        email=body.email,\n        password_hash=hash_password(body.password),\n        role=\"admin\",\n    )\n    db.add(user)\n    try:\n        db.commit()\n    except IntegrityError:\n        db.rollback()\n        raise HTTPException(status_code=403, detail=\"Registration is closed. An admin account already exists.\")\n    db.refresh(user)\n\n    capture_admin_registered(email=body.email)\n\n    return TokenResponse(","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/server/routers/auth.py#L83-L119","documentation":"Error \"Registration is closed. An admin account already exists.\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at server/routers/auth.py:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Registration is closed after the first admin account; log in with the existing account or reset the database."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}