toeverything/AFFiNE · error · UserNotFound

user_not_found

user_not_found

Error message

User not found.

What it means

Thrown by UserModel.fulfill (user.ts:256) when the user matching the email exists but is disabled. fulfill is used to register/verify a user during invitation acceptance or email verification; a disabled user cannot be fulfilled. UserFriendlyError, code user_not_found, type resource_not_found, HTTP 404.

Source

Thrown at packages/backend/server/src/models/user.ts:256

  /**
   * Mark a existing user or create a new one as registered and email verified.
   *
   * When user created by others invitation, we will leave it as unregistered.
   */
  async fulfill(email: string, data: Omit<UpdateUserInput, 'email'> = {}) {
    const user = await this.getUserByEmail(email, { withDisabled: true });

    if (!user) {
      return this.create({
        email,
        registered: true,
        emailVerifiedAt: new Date(),
        ...data,
      });
    } else {
      if (user.disabled) {
        throw new UserNotFound();
      }

      if (user.registered) {
        delete data.registered;
      } else {
        data.registered = true;
      }

      if (user.emailVerifiedAt) {
        delete data.emailVerifiedAt;
      } else {
        data.emailVerifiedAt = new Date();
      }

      if (Object.keys(data).length) {
        return await this.update(user.id, data);
      }
    }

View on GitHub (pinned to 26c515e050)

Solutions

  1. Have an admin re-enable the account, then retry the link.
  2. If the disable was intentional, reject the flow in the UI rather than retrying.
  3. Avoid sending invitations to disabled users.
Defensive patterns

Strategy: try-catch

Try / catch

import { UserNotFound } from '../base/error/errors.gen';

try {
  await models.user.fulfill(email, data);
} catch (e) {
  if (e instanceof UserNotFound) {
    // account is disabled; surface 'contact admin to re-enable'
  } else throw e;
}

Prevention

When it happens

Trigger: A disabled user clicks an invitation or email-verification link; an OAuth callback runs for a disabled account; fulfill() is invoked on an email whose only record is disabled.

Common situations: Admin disabled the user between sending the invite and the user accepting; a banned user attempts to verify; an offboarding pipeline disabled the account mid-flow.

Related errors


AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12). Data as JSON: /api/errors/3d9b361d779b1704. Report an issue: GitHub.