{"record":{"id":"49520142d51bc127","repo":"different-ai/openwork","slug":"failed-to-update-profile-response-status","errorCode":null,"errorMessage":"Failed to update profile (${response.status}).","messagePattern":"Failed to update profile \\((.+?)\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/_providers/den-flow-provider.tsx","lineNumber":1420,"sourceCode":"      window.localStorage.removeItem(LAST_WORKER_STORAGE_KEY);\n      window.sessionStorage.removeItem(PENDING_SOCIAL_SIGNUP_STORAGE_KEY);\n      window.sessionStorage.removeItem(PENDING_ORG_INVITATION_STORAGE_KEY);\n      window.sessionStorage.removeItem(PENDING_WORKSPACE_CLAIM_STORAGE_KEY);\n    }\n  }\n\n  async function updateUserProfile(input: { firstName: string; lastName: string }) {\n    const { response, payload } = await requestJson(\n      \"/v1/me/profile\",\n      {\n        method: \"PATCH\",\n        body: JSON.stringify(input),\n      },\n      12000,\n    );\n\n    if (!response.ok) {\n      throw new Error(getErrorMessage(payload, `Failed to update profile (${response.status}).`));\n    }\n\n    const nextUser = getUser(payload);\n    if (!nextUser) {\n      throw new Error(\"Profile update response did not include a user.\");\n    }\n\n    setUser(nextUser);\n    identifyPosthogUser(nextUser);\n    return nextUser;\n  }\n\n  async function launchWorker(options: { source?: \"manual\" | \"signup_auto\"; workerNameOverride?: string } = {}) {\n    if (!user) {\n      setAuthError(\"Sign in before launching a worker.\");\n      return \"error\" as const;\n    }\n","sourceCodeStart":1402,"sourceCodeEnd":1438,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/_providers/den-flow-provider.tsx#L1402-L1438","documentation":"den-flow-provider.tsx throws this when the profile-update request (POST with JSON body, 12s timeout) returns a non-ok status, embedding the status code as the fallback message. It indicates the server rejected or failed the profile change and returned no parseable error detail.","triggerScenarios":"`requestJson` profile update responds with response.ok === false — e.g. 401 expired session, 403 forbidden field change, 422 invalid input (bad name/avatar payload), or 500 server error.","commonSituations":"Session expired while the user was editing their profile (401); user submits an invalid avatar URL or over-long name (422); server-side update conflict (409); Den server outage (5xx).","solutions":["Check the interpolated status code and the request payload in the network tab","Re-authenticate if the status is 401, then re-apply the profile change","Validate the submitted fields client-side (length, format) to prevent 422s","Retry after confirming the Den server is healthy for 5xx responses"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const input = { name: nameInput.trim(), avatarUrl: avatarUrlInput.trim() };\nif (input.name.length === 0 || input.name.length > 64 || (input.avatarUrl && !URL.canParse(input.avatarUrl))) {\n  setError(\"Check your profile fields before saving.\");\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await updateProfile(input);\n} catch (err) {\n  const m = err.message.match(/\\((\\d{3})\\)/);\n  if (m?.[1] === \"401\") { await reauth(); retryUpdateProfile(input); }\n  else showError(\"Could not save your profile. Check your fields and try again.\");\n}","preventionTips":["Validate profile fields client-side (name length, avatar URL format) to avoid 422s","Detect 401 early and refresh the session instead of failing the save","Keep the server's JSON error contract so getErrorMessage surfaces real causes","Disable the save button while a request is in flight to prevent duplicate/conflicting updates"],"tags":["http","fetch","den-web","profile"],"backgroundTag":"api-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}