{"record":{"id":"2a6555c1e179b2ae","repo":"toeverything/AFFiNE","slug":"failed-to-create-admin","errorCode":null,"errorMessage":"Failed to create admin","messagePattern":"Failed to create admin","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/admin/src/modules/setup/form.tsx","lineNumber":113,"sourceCode":"  }, [api, serverConfig.initialized, navigate]);\n\n  const createAdmin = useCallback(async () => {\n    try {\n      const createResponse = await affineFetch('/api/setup/create-admin-user', {\n        method: 'POST',\n        body: JSON.stringify({\n          name: nameValue,\n          email: emailValue,\n          password: passwordValue,\n        }),\n        headers: {\n          'Content-Type': 'application/json',\n        },\n      });\n\n      if (!createResponse.ok) {\n        const errorData = await createResponse.json();\n        throw new Error(errorData.message || 'Failed to create admin');\n      }\n\n      await createResponse.json();\n      await refreshServerConfig();\n      toast.success('Admin account created successfully.');\n    } catch (err) {\n      toast.error((err as Error).message);\n      console.error(err);\n      throw err;\n    }\n  }, [nameValue, emailValue, passwordValue, refreshServerConfig]);\n\n  const onNext = useAsyncCallback(async () => {\n    if (isCreateAdminStep) {\n      if (\n        !validateEmailAndPassword(\n          emailValue,\n          passwordValue,","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/admin/src/modules/setup/form.tsx#L95-L131","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the server logs for the creation failure cause.","Ensure the setup has not already been completed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}