{"record":{"id":"a5903faebc7513a0","repo":"moeru-ai/airi","slug":"deleteuser-failed","errorCode":null,"errorMessage":"deleteUser failed","messagePattern":"deleteUser failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/account/account-settings-page.vue","lineNumber":392,"sourceCode":"async function handleConfirmDelete(event: Event) {\n  event.preventDefault()\n  if (deleteLoading.value || !deleteEmailMatches.value)\n    return\n\n  deleteError.value = null\n  deleteLoading.value = true\n\n  try {\n    // The success page lives on the API-server origin (shared\n    // ui-server-auth bundle). It tells the user the deletion completed\n    // and asks them to close the tab — there is no \"back to home\"\n    // because the API server has no reliable way to know which calling\n    // app origin (stage-web / stage-tamagotchi / stage-pocket) the\n    // request came from.\n    const callbackURL = new URL('/auth/delete-account', SERVER_URL).toString()\n    const { error } = await authClient.deleteUser({ callbackURL })\n    if (error)\n      throw new Error(error.message ?? 'deleteUser failed')\n\n    deleteSent.value = true\n    deleteDialogOpen.value = false\n    trackAccountDeletionRequested()\n  }\n  catch (error) {\n    deleteError.value = errorMessageFrom(error) ?? t('settings.pages.account.danger.deleteAccount.error.fallback')\n  }\n  finally {\n    deleteLoading.value = false\n  }\n}\n</script>\n\n<template>\n  <div :class=\"['flex flex-col gap-6', 'p-4']\">\n    <template v-if=\"isAuthenticated\">\n      <!-- 2-col layout on md+; pure single-column on mobile. The sidebar is","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/account/account-settings-page.vue#L374-L410","documentation":"Wraps authClient.deleteUser({ callbackURL }); the literal fires only when better-auth's error has no message. Deletion runs server-side and the user lands on the API-origin success page because the server cannot know which app origin (stage-web / stage-tamagotchi / stage-pocket) initiated the request.","triggerScenarios":"Expired session (401); the server requiring recent re-auth or an additional factor for deletion; auth server unreachable; user abandons the email-confirmation flow where that plugin is enabled.","commonSituations":"Long-lived settings tab with a stale session; auth server restart mid-flow; custom better-auth plugins adding deletion constraints.","solutions":["Re-authenticate and retry the deletion.","Log error.status/code from deleteUser to identify the rejection reason.","Confirm the auth server is up and the delete-account route/plugin is enabled.","Verify callbackURL builds correctly from SERVER_URL."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!authStore.user) {\n  deleteError.value = 'Session expired — sign in again'\n  return\n}","typeGuard":null,"tryCatchPattern":"catch (error) {\n  if ((error as { status?: number })?.status === 401)\n    await redirectToSignIn()\n  else\n    deleteError.value = errorMessageFrom(error) ?? t('settings.pages.account.danger.deleteAccount.error.fallback')\n}","preventionTips":["Require a fresh session before destructive account actions.","Keep the confirmation dialog explicit about irreversibility.","Track deletion requests (the page already calls trackAccountDeletionRequested) for support debugging."],"tags":["auth","better-auth","account-deletion","account"],"backgroundTag":"auth-api-error","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}