{"record":{"id":"47c3400c6a8f8fe6","repo":"moeru-ai/airi","slug":"updateuser-failed","errorCode":null,"errorMessage":"updateUser failed","messagePattern":"updateUser failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/ui-server-auth/src/modules/profile.ts","lineNumber":129,"sourceCode":" * Update the signed-in user's display name and/or avatar.\n *\n * Use when:\n * - Saving the \"display name\" form on the profile page.\n *\n * Expects:\n * - Caller has already trimmed `name` and confirmed it's non-empty.\n * - `image` is either an absolute URL or `null` (clear).\n */\nexport async function updateUserProfile(args: UpdateUserProfileArgs): Promise<void> {\n  const client = getAuthClient(args)\n  const body: { name?: string, image?: string | null } = {}\n  if (args.name !== undefined)\n    body.name = args.name\n  if (args.image !== undefined)\n    body.image = args.image\n  const { error } = await client.updateUser(body)\n  if (error)\n    throw new Error(error.message ?? 'updateUser failed')\n}\n\n/**\n * Change the signed-in user's password using their current credential.\n *\n * Use when:\n * - User is signed in and wants to rotate their password from the profile\n *   page (not the forgot-password email flow).\n *\n * Expects:\n * - The user has a `credential` account; social-only users get a server-side\n *   error which surfaces as a thrown `Error` here.\n */\nexport async function changePassword(args: ChangePasswordArgs): Promise<void> {\n  const client = getAuthClient(args)\n  const { error } = await client.changePassword({\n    currentPassword: args.currentPassword,\n    newPassword: args.newPassword,","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/ui-server-auth/src/modules/profile.ts#L111-L147","documentation":"Thrown by updateUserProfile when better-auth's client.updateUser returns an error. The body only includes name and/or image when those args are defined. The fallback message 'updateUser failed' is used only when the server error lacks a message. Common server-side causes: name validation failure, image URL rejected, or rate limiting.","triggerScenarios":"Saving the profile form with a name the server rejects (too long, banned word); passing an image that is not an absolute URL or that fails server-side upload validation; the session expired between load and save so updateUser 401s.","commonSituations":"User edits display name to an empty/whitespace string after the caller skipped trimming; avatar URL is relative or malformed; concurrent sign-out invalidated the session; server-side image processing failed.","solutions":["Trim name and confirm non-empty before calling (the docstring expects the caller to have done this).","Ensure image is an absolute URL or null (null clears it); reject relative paths client-side.","Read error.message for the server's specific reason and surface it to the form field.","If the session lapsed, re-authenticate before retrying the update."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const name = args.name?.trim()\nif (args.name !== undefined && !name)\n  throw new Error('Display name cannot be empty.')\nif (args.image !== undefined && args.image !== null) {\n  try { new URL(args.image) } catch { throw new Error('Image must be an absolute URL.') }\n}\nawait updateUserProfile({ ...args, name })","typeGuard":"function isValidProfileUpdate(args) {\n  if (args.name !== undefined && !args.name.trim()) return false\n  if (args.image !== undefined && args.image !== null) {\n    try { new URL(args.image) } catch { return false }\n  }\n  return true\n}","tryCatchPattern":"try {\n  await updateUserProfile(args)\n} catch (e) {\n  // e.message carries the server reason; map to the offending form field\n}","preventionTips":["Trim name and reject empty before calling.","Validate image is an absolute URL or null client-side.","Surface server messages verbatim to the relevant field."],"tags":["auth","profile","better-auth","validation","ui-server-auth"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}