toeverything/AFFiNE · error · Error

Failed to create admin

Error message

Failed to create admin

What it means

Admin setup form: thrown when /api/setup/create-admin-user responds non-ok; the server's error message is used when present, otherwise the generic 'Failed to create admin' sentinel indicates the initial admin account could not be provisioned.

Solutions

  1. Check the server logs for the creation failure cause.
  2. Ensure the setup has not already been completed.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown when the create-admin request during initial server setup returns a non-OK status and the error payload has no message, so a generic creation failure is raised.

Common situations: First-time setup of a self-hosted server fails while creating the admin account. Check server logs, confirm the server is not already initialized, and retry.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/2a6555c1e179b2ae. Report an issue: GitHub.

Appendix: source

Thrown at packages/frontend/admin/src/modules/setup/form.tsx:113

  }, [api, serverConfig.initialized, navigate]);

  const createAdmin = useCallback(async () => {
    try {
      const createResponse = await affineFetch('/api/setup/create-admin-user', {
        method: 'POST',
        body: JSON.stringify({
          name: nameValue,
          email: emailValue,
          password: passwordValue,
        }),
        headers: {
          'Content-Type': 'application/json',
        },
      });

      if (!createResponse.ok) {
        const errorData = await createResponse.json();
        throw new Error(errorData.message || 'Failed to create admin');
      }

      await createResponse.json();
      await refreshServerConfig();
      toast.success('Admin account created successfully.');
    } catch (err) {
      toast.error((err as Error).message);
      console.error(err);
      throw err;
    }
  }, [nameValue, emailValue, passwordValue, refreshServerConfig]);

  const onNext = useAsyncCallback(async () => {
    if (isCreateAdminStep) {
      if (
        !validateEmailAndPassword(
          emailValue,
          passwordValue,

View on GitHub (pinned to b4c8548c09)