{"record":{"id":"4a977af5fdcb4e75","repo":"different-ai/openwork","slug":"failed-to-update-organization-response-status","errorCode":null,"errorMessage":"Failed to update organization (${response.status}).","messagePattern":"Failed to update organization \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx","lineNumber":558,"sourceCode":"      body.brandIconUrl = input.brandIconUrl;\n    }\n    if (input.brandAccentColor !== undefined) {\n      body.brandAccentColor = input.brandAccentColor;\n    }\n\n    await runMutation(\"update-organization-settings\", async () => {\n      ensureActiveOrganizationSelected();\n      const { response, payload } = await requestJson(\n        \"/v1/org\",\n        {\n          method: \"PATCH\",\n          body: JSON.stringify(body),\n        },\n        12000,\n      );\n\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to update organization (${response.status}).`);\n      }\n    });\n\n    if (shouldPublishOrgSettingsCompletion && pathnameRef.current === ORG_SETTINGS_PATH) {\n      publishOrgSettingsCompletion();\n    }\n  }\n\n  async function deleteOrganization() {\n    ensureCanDeleteOrganization();\n\n    await runReauthableAction(\"delete-organization\", async () => {\n      ensureActiveOrganizationSelected();\n      const { response, payload } = await requestJson(\n        \"/v1/org\",\n        { method: \"DELETE\" },\n        12000,\n      );","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx#L540-L576","documentation":"Thrown by updateOrganizationSettings (invoked by updateOrganizationName) in org-dashboard-provider.tsx when the organization settings POST returns non-ok. The request is wrapped in runReauthableAction, so 403 reauth challenges are retried after re-authentication; all other failures propagate this error with the server's message. On success — and when still on ORG_SETTINGS_PATH — a completion event is published.","triggerScenarios":"POST of the org settings body (name and related fields) with a 12s timeout returns 400 (invalid name: empty, too long, forbidden characters), 401 (expired session), 403 (not org owner/admin, or reauth challenge), 404 (orgId invalid), 409 (name conflict), 429, or 5xx. shouldPublishOrgSettingsCompletion gates the success path, so the error happens before any completion event fires.","commonSituations":"Renaming an org as a member without owner/admin rights; pasting a name exceeding server length limits; org id in the provider state stale after the user switched orgs; Den server outage.","solutions":["Read the appended server message — name validation failures state the exact constraint.","Validate the name client-side (non-empty, length/slug constraints) before calling updateOrganizationName.","On 403 confirm the user is an org owner/admin; ReauthRequiredError is handled by runReauthableAction — ensure the caller doesn't swallow its retry flow.","If 404/409, refresh the org list; the org may have been renamed/deleted elsewhere.","Retry on 429/5xx; investigate Den server health if persistent."],"exampleFix":"// before\nawait updateOrganizationName(name);\n// after: pre-validate the name\nconst trimmed = name.trim();\nif (!trimmed || trimmed.length > 64) {\n  setError(\"Organization name must be 1-64 characters.\");\n  return;\n}\nawait updateOrganizationName(trimmed);","handlingStrategy":"validation","validationCode":"const name = candidate.trim();\nif (!name) throw new Error(\"Organization name cannot be empty.\");\nif (name.length > 64) throw new Error(\"Organization name must be at most 64 characters.\");\nif (!orgId) throw new Error(\"No organization selected.\");","typeGuard":"function isReauthRequiredError(e: unknown): e is ReauthRequiredError {\n  return e instanceof ReauthRequiredError;\n}","tryCatchPattern":"try {\n  await updateOrganizationSettings(body);\n} catch (err) {\n  if (isReauthRequiredError(err)) return; // runReauthableAction already handled retry\n  if (/\\b(403|404)\\b/.test(err.message)) { setError(\"You need org owner/admin rights for this organization.\"); return; }\n  setError(err.message);\n}","preventionTips":["Validate the org name (non-empty, length, allowed characters) before sending.","Only expose org settings editing to owner/admin roles.","Ensure orgId in provider state matches the org the user is actively viewing; refresh on org switch.","Keep the mutation inside runReauthableAction so 403 reauth is retried transparently.","Publish completion only after success (shouldPublishOrgSettingsCompletion path already enforces this)."],"tags":["http","api","organization","settings","den-web"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}