{"record":{"id":"a33832f9cbbe6e9b","repo":"infiniflow/ragflow","slug":"failed-to-register-user-info-email","errorCode":null,"errorMessage":"Failed to register {user_info.email}","messagePattern":"Failed to register (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":302,"severity":"error","filePath":"api/apps/restful_apis/user_api.py","lineNumber":246,"sourceCode":"                except Exception as e:\n                    logging.exception(e)\n                    avatar = \"\"\n\n                users = user_register(\n                    user_id,\n                    {\n                        \"access_token\": get_uuid(),\n                        \"email\": user_info.email,\n                        \"avatar\": avatar,\n                        \"nickname\": user_info.nickname,\n                        \"login_channel\": channel,\n                        \"last_login_time\": get_format_time(),\n                        \"is_superuser\": False,\n                    },\n                )\n\n                if not users:\n                    raise Exception(f\"Failed to register {user_info.email}\")\n                if len(users) > 1:\n                    raise Exception(f\"Same email: {user_info.email} exists!\")\n\n                # Try to log in\n                user = users[0]\n                login_user(user)\n                return redirect(f\"/?auth={user.get_id()}\")\n\n            except Exception as e:\n                rollback_user_registration(user_id)\n                logging.exception(e)\n                return redirect(f\"/?error={str(e)}\")\n\n        # User exists, try to log in\n        user = users[0]\n        user.access_token = get_uuid()\n        if user and hasattr(user, \"is_active\") and user.is_active == \"0\":\n            return redirect(\"/?error=user_inactive\")","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/restful_apis/user_api.py#L228-L264","documentation":"Raised during OAuth first-login registration when user_register() returns an empty/None result for the new user id, meaning the insert did not produce a user row (the generated uuid was already taken or the save failed silently). The handler rolls back the registration and redirects to /?error=<message>.","triggerScenarios":"OAuth callback for a brand-new email where UserService.save/user_register fails to persist (DB error swallowed, duplicate uuid collision) and the subsequent query by user_id returns no rows.","commonSituations":"Database permission/constraint problems on the user table, interrupted deploys, or (rarely) uuid collisions; typically surfaces alongside DB errors in server logs.","solutions":["Check server logs for the exception logged by logging.exception right after the redirect occurs — the root DB error is there.","Verify the database user has INSERT on the user table and no unique-constraint violations exist for the email.","Retry the OAuth login; transient DB failures usually clear.","If persistent, inspect user_register/save for swallowed exceptions in your deployment."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"def can_register(email):\n    users = UserService.query(email=email)\n    return not users  # ensure email not taken before starting OAuth flow","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        user = complete_oauth_registration(user_info)\n        break\n    except Exception as e:\n        if \"Failed to register\" in str(e) and attempt == 0:\n            continue\n        raise","preventionTips":["Treat this error as a DB symptom: check logs for the root exception immediately.","Keep unique constraints on user.email so silent duplicates surface early.","Idempotent retry wrappers around OAuth first-login handle transient insert failures."],"tags":["auth","oauth","registration","database"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}