infiniflow/ragflow · error · UserNotFoundError

404

404

Error message

User '{username}' not found

What it means

UserNotFoundError (HTTP 404) raised by UserServiceMgr.get_user_datasets (admin/server/services.py:239) when query_user_by_email returns no rows. Dataset listing resolves the user first, then enumerates tenants via TenantService.get_joined_tenants_by_user_id to fetch knowledge bases; an unknown email stops before any tenant query.

Source

Thrown at admin/server/services.py:239

            raise UserNotFoundError(username)
        elif len(user_list) > 1:
            raise AdminException(f"Exist more than 1 user: {username}!")
        # check activate status different from new
        usr = user_list[0]
        if not usr.is_superuser:
            return f"{usr} isn't superuser, yet!"
        # update is_active
        UserService.update_user(usr.id, {"is_superuser": False})
        return "Revoke successfully!"


class UserServiceMgr:
    @staticmethod
    def get_user_datasets(username):
        # use email to find user.
        user_list = UserService.query_user_by_email(username)
        if not user_list:
            raise UserNotFoundError(username)
        elif len(user_list) > 1:
            raise AdminException(f"Exist more than 1 user: {username}!")
        # find tenants
        usr = user_list[0]
        tenants = TenantService.get_joined_tenants_by_user_id(usr.id)
        tenant_ids = [m["tenant_id"] for m in tenants]
        # filter permitted kb and owned kb
        return KnowledgebaseService.get_all_kb_by_tenant_ids(tenant_ids, usr.id)

    @staticmethod
    def get_user_agents(username):
        # use email to find user.
        user_list = UserService.query_user_by_email(username)
        if not user_list:
            raise UserNotFoundError(username)
        elif len(user_list) > 1:
            raise AdminException(f"Exist more than 1 user: {username}!")
        # find tenants

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Confirm the account with get_user_details/get_all_users before listing datasets.
  2. Treat 404 as an empty dataset list in reporting tools.
  3. Use the exact stored email string.
  4. Verify the target database/environment.

Example fix

# before
kbs = UserServiceMgr.get_user_datasets('user@example.com')  # 404

# after
from admin.server.exceptions import UserNotFoundError
try:
    kbs = UserServiceMgr.get_user_datasets('user@example.com')
except UserNotFoundError:
    kbs = []
Defensive patterns

Strategy: try-catch

Validate before calling

from api.db.services import UserService

def user_resolvable(email: str) -> bool:
    return len(UserService.query_user_by_email(email.strip())) == 1

Try / catch

from admin.server.exceptions import UserNotFoundError
try:
    kbs = UserServiceMgr.get_user_datasets(email)
except UserNotFoundError:
    kbs = []

Prevention

When it happens

Trigger: Listing datasets for a nonexistent, deleted, or typo'd email; passing a user id or nickname where the login email is required.

Common situations: Support tooling auditing a user's KBs after offboarding; environment drift; users whose stored email differs from what support expects (SSO aliases, profile edits).

Related errors


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