{"record":{"id":"1bb02a55fcad44f7","repo":"iOfficeAI/AionUi","slug":"webui-api-webui-reset-password-returned-reset","errorCode":null,"errorMessage":"[WebUI] /api/webui/reset-password returned ${resetRes.status}","messagePattern":"\\[WebUI\\] /api/webui/reset-password returned (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/process/bridge/webuiBridge.ts","lineNumber":69,"sourceCode":" */\nasync function maybeSeedInitialPassword(): Promise<void> {\n  const port = getBackendPort();\n  if (!port) {\n    throw new Error('[WebUI] Cannot start: aioncore is not running (globalThis.__backendPort unset)');\n  }\n  const statusRes = await fetch(`http://127.0.0.1:${port}/api/auth/status`);\n  if (!statusRes.ok) {\n    throw new Error(`[WebUI] /api/auth/status returned ${statusRes.status}`);\n  }\n  const statusJson = (await statusRes.json()) as { needs_setup?: boolean; data?: { needs_setup?: boolean } };\n  const needsSetup = statusJson.needs_setup ?? statusJson.data?.needs_setup ?? false;\n  if (!needsSetup) {\n    setDesktopWebUIInitialPassword(undefined);\n    return;\n  }\n  const resetRes = await fetch(`http://127.0.0.1:${port}/api/webui/reset-password`, { method: 'POST' });\n  if (!resetRes.ok) {\n    throw new Error(`[WebUI] /api/webui/reset-password returned ${resetRes.status}`);\n  }\n  const resetJson = (await resetRes.json()) as { data?: { new_password?: string }; new_password?: string };\n  const newPassword = resetJson.data?.new_password ?? resetJson.new_password;\n  if (!newPassword) {\n    throw new Error('[WebUI] /api/webui/reset-password returned no new_password');\n  }\n  setDesktopWebUIInitialPassword(newPassword);\n}\n\nexport function initWebuiBridge(): void {\n  ipcBridge.webui.getStatus.provider(async () => {\n    const snapshot = getDesktopWebUIStatus();\n    const adminUsername = await fetchAdminUsername();\n    return { ...snapshot, adminUsername };\n  });\n\n  ipcBridge.webui.start.provider(async (params) => {\n    await maybeSeedInitialPassword();","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/process/bridge/webuiBridge.ts#L51-L87","documentation":"Thrown when POST /api/webui/reset-password on the local backend returns a non-2xx status during WebUI initial-password seeding. The HTTP status is included in the message.","triggerScenarios":"The backend responds 4xx/5xx to the unauthenticated reset-password request — e.g. the endpoint rejects the call because setup is not actually pending, or the backend errors while resetting.","commonSituations":"Race where another process already completed setup between the status check and the reset call, backend version mismatch removing/changing the endpoint, or backend internal error (DB locked/corrupt).","solutions":["Re-check /api/auth/status — if needs_setup flipped to false, seeding should be skipped, not reset","curl -X POST the reset-password endpoint and read the response body for the backend's error detail","Check backend logs for the failed reset (DB errors, validation errors)","Confirm backend version compatibility with the desktop client"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const status = await fetch(`http://127.0.0.1:${port}/api/auth/status`).then((r) => r.json());\nif (!status.needs_setup && !status.data?.needs_setup) { /* skip reset: nothing to seed */ }","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (/reset-password returned/.test(err.message)) {\n    const s = await fetchStatus(); // maybe setup completed elsewhere\n    if (!needsSetup(s)) return; // benign race\n  }\n  throw err;\n}","preventionTips":["Re-verify needs_setup immediately before resetting","Treat concurrent seeding as a benign race","Contract-test the reset endpoint between desktop and backend releases"],"tags":["webui","password-reset","http-status","auth"],"backgroundTag":"password-reset-failed","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}