{"record":{"id":"29e2306d32538579","repo":"mem0ai/mem0","slug":"admin-role-required","errorCode":null,"errorMessage":"Admin role required.","messagePattern":"Admin role required\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"server/auth.py","lineNumber":214,"sourceCode":"\n\nasync def require_admin(\n    request: Request,\n    user: User | None = Depends(verify_auth),\n) -> User:\n    \"\"\"Like require_auth but also enforces admin role.\n\n    ADMIN_API_KEY and AUTH_DISABLED callers are treated as admin even when\n    the users table is empty (fresh-deploy bootstrap).\n    \"\"\"\n    auth_type = getattr(request.state, \"auth_type\", \"none\")\n    if user is None:\n        if auth_type in {\"admin_api_key\", \"disabled\"}:\n            with SessionLocal() as db:\n                default_user = _get_default_user(db)\n            if default_user is not None:\n                if default_user.role != \"admin\":\n                    raise HTTPException(status_code=403, detail=\"Admin role required.\")\n                return default_user\n            return _BOOTSTRAP_ADMIN\n        raise HTTPException(status_code=401, detail=\"Authentication required.\")\n    if user.role != \"admin\":\n        raise HTTPException(status_code=403, detail=\"Admin role required.\")\n    return user\n","sourceCodeStart":196,"sourceCodeEnd":221,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/server/auth.py#L196-L221","documentation":"Error \"Admin role required.\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at server/auth.py:214 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an account with the admin role to call this endpoint."],"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-15T17:31:12.345Z"}