infiniflow/ragflow · error · Exception

Failed to register {user_info.email}

Error message

Failed to register {user_info.email}

What it means

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>.

Source

Thrown at api/apps/restful_apis/user_api.py:246

                except Exception as e:
                    logging.exception(e)
                    avatar = ""

                users = user_register(
                    user_id,
                    {
                        "access_token": get_uuid(),
                        "email": user_info.email,
                        "avatar": avatar,
                        "nickname": user_info.nickname,
                        "login_channel": channel,
                        "last_login_time": get_format_time(),
                        "is_superuser": False,
                    },
                )

                if not users:
                    raise Exception(f"Failed to register {user_info.email}")
                if len(users) > 1:
                    raise Exception(f"Same email: {user_info.email} exists!")

                # Try to log in
                user = users[0]
                login_user(user)
                return redirect(f"/?auth={user.get_id()}")

            except Exception as e:
                rollback_user_registration(user_id)
                logging.exception(e)
                return redirect(f"/?error={str(e)}")

        # User exists, try to log in
        user = users[0]
        user.access_token = get_uuid()
        if user and hasattr(user, "is_active") and user.is_active == "0":
            return redirect("/?error=user_inactive")

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Check server logs for the exception logged by logging.exception right after the redirect occurs — the root DB error is there.
  2. Verify the database user has INSERT on the user table and no unique-constraint violations exist for the email.
  3. Retry the OAuth login; transient DB failures usually clear.
  4. If persistent, inspect user_register/save for swallowed exceptions in your deployment.
Defensive patterns

Strategy: retry

Validate before calling

def can_register(email):
    users = UserService.query(email=email)
    return not users  # ensure email not taken before starting OAuth flow

Try / catch

for attempt in range(2):
    try:
        user = complete_oauth_registration(user_info)
        break
    except Exception as e:
        if "Failed to register" in str(e) and attempt == 0:
            continue
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Database permission/constraint problems on the user table, interrupted deploys, or (rarely) uuid collisions; typically surfaces alongside DB errors in server logs.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/a33832f9cbbe6e9b. Report an issue: GitHub.