{"record":{"id":"8115c0bfd64d62fa","repo":"HKUDS/DeepTutor","slug":"registration-failed-username-or-email-may-alread","errorCode":null,"errorMessage":"Registration failed — username or email may already be taken.","messagePattern":"Registration failed — username or email may already be taken\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":521,"sourceCode":"    Only available when AUTH_ENABLED=true.\n    \"\"\"\n    if not AUTH_ENABLED:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Auth is disabled — registration is not available.\",\n        )\n\n    if POCKETBASE_ENABLED:\n        # PocketBase deployments are documented as single-user. Keep registration\n        # closed and require admins to provision users in the PocketBase admin UI.\n        if not is_first_user():\n            raise HTTPException(\n                status_code=status.HTTP_403_FORBIDDEN,\n                detail=\"Self-registration is closed. Ask an administrator to create your account.\",\n            )\n        result = register_pb(username=body.username, email=body.username, password=body.password)\n        if not result:\n            raise HTTPException(\n                status_code=status.HTTP_409_CONFLICT,\n                detail=\"Registration failed — username or email may already be taken.\",\n            )\n        logger.info(f\"First user registered via PocketBase: '{body.username}'\")\n        return {\n            \"ok\": True,\n            \"user_id\": result.get(\"id\", \"\"),\n            \"username\": body.username,\n            \"role\": \"user\",\n            \"is_first_user\": True,\n            \"is_admin\": False,\n        }\n\n    # Standard mode — only allowed before the first admin exists.\n    if not is_first_user():\n        raise HTTPException(\n            status_code=status.HTTP_403_FORBIDDEN,\n            detail=\"Self-registration is closed. Ask an administrator to create your account.\",","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L503-L539","documentation":"Error \"Registration failed — username or email may already be taken.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:521 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}