{"record":{"id":"5f101a02a428bb16","repo":"moeru-ai/airi","slug":"changepassword-failed","errorCode":null,"errorMessage":"changePassword failed","messagePattern":"changePassword failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/account/account-settings-page.vue","lineNumber":277,"sourceCode":"\n  if (passwordForm.next !== passwordForm.confirm) {\n    passwordError.value = t('settings.pages.account.security.error.passwordMismatch')\n    return\n  }\n  if (passwordForm.next === passwordForm.current) {\n    passwordError.value = t('settings.pages.account.security.error.passwordSameAsCurrent')\n    return\n  }\n\n  passwordLoading.value = true\n  try {\n    const { error } = await authClient.changePassword({\n      currentPassword: passwordForm.current,\n      newPassword: passwordForm.next,\n      revokeOtherSessions: true,\n    })\n    if (error)\n      throw new Error(error.message ?? 'changePassword failed')\n\n    passwordForm.current = ''\n    passwordForm.next = ''\n    passwordForm.confirm = ''\n    passwordSuccess.value = t('settings.pages.account.security.message.changed')\n    trackPasswordChanged()\n  }\n  catch (error) {\n    passwordError.value = errorMessageFrom(error) ?? t('settings.pages.account.security.error.fallback')\n  }\n  finally {\n    passwordLoading.value = false\n  }\n}\n\nasync function handleSendSetPasswordLink() {\n  const email = userEmail.value\n  if (setPasswordLoading.value || !email)","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/account/account-settings-page.vue#L259-L295","documentation":"The password-change handler wraps better-auth's authClient.changePassword (with revokeOtherSessions: true); the literal fires only when the returned error has no message. Real causes: wrong currentPassword, a new password violating server policy, or an expired session.","triggerScenarios":"currentPassword mismatch (server rejects with an invalid-password style error); newPassword below the server's minimum policy; 401 from an expired session; auth server unreachable.","commonSituations":"Typo in the current password; password managers autofilling wrong fields; server password policy stricter than the client expects.","solutions":["Verify currentPassword and confirm the new password meets the server policy.","Log error.status/code from changePassword to distinguish invalid-password from session errors.","Re-login on 401 and retry.","Ensure the auth app is reachable at SERVER_URL."],"exampleFix":"// before\nif (error)\n  throw new Error(error.message ?? 'changePassword failed')\n\n// after\nif (error)\n  throw new Error(error.message ?? `changePassword failed (${error.status ?? 'no status'} ${error.code ?? ''})`)","handlingStrategy":"try-catch","validationCode":"if (passwordForm.next !== passwordForm.confirm)\n  return // block submit\nif (passwordForm.next.length < 8)\n  return // block submit\nif (passwordForm.next === passwordForm.current) {\n  passwordError.value = t('settings.pages.account.security.error.passwordSameAsCurrent')\n  return\n}","typeGuard":null,"tryCatchPattern":"catch (error) {\n  const msg = errorMessageFrom(error) ?? ''\n  if (msg.toLowerCase().includes('invalid password'))\n    passwordError.value = 'Current password is incorrect'\n  else if ((error as { status?: number })?.status === 401)\n    await redirectToSignIn()\n  else\n    passwordError.value = msg || t('settings.pages.account.security.error.fallback')\n}","preventionTips":["Mirror the server password policy client-side.","Never discard error.code — it distinguishes failure modes.","Clear password fields only on success, as the page already does."],"tags":["auth","better-auth","password","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-23T08:17:48.524Z"}