{"record":{"id":"e7cfd477e6656f65","repo":"different-ai/openwork","slug":"failed-to-update-inference-settings-response-st","errorCode":null,"errorMessage":"Failed to update inference settings (${response.status}).","messagePattern":"Failed to update inference settings \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/inference-screen.tsx","lineNumber":397,"sourceCode":"    if (status.enabled || !status.subscribed) {\n      router.push(getBillingRoute(activeOrg?.slug));\n      return;\n    }\n    setError(null);\n    try {\n      await runReauthableAction(\"update-inference\", async () => {\n        setSaving(true);\n        try {\n          const { response, payload } = await requestJson(\n            \"/v1/inference\",\n            {\n              method: \"PATCH\",\n              body: JSON.stringify({ enabled: !status.enabled, tier: status.tier }),\n            },\n            20000,\n          );\n          if (!response.ok) {\n            throw getRequestError(payload, response, `Failed to update inference settings (${response.status}).`);\n          }\n          const parsed = parseInferencePayload(payload);\n          if (!parsed) {\n            throw new Error(\"Inference settings response was incomplete.\");\n          }\n          setStatus(parsed);\n          await refreshOrgData();\n        } finally {\n          setSaving(false);\n        }\n      });\n    } catch (saveError) {\n      setError(saveError instanceof Error ? saveError.message : \"Failed to update inference settings.\");\n    }\n  }\n\n  if (isSelfHosted) {\n    return null;","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/inference-screen.tsx#L379-L415","documentation":"Thrown by toggleEnabled when PATCH /v1/inference/settings (enabling/disabling inference with the current tier) returns non-OK. getRequestError throws ReauthRequiredError for 403 reauth payloads or the server message / this fallback otherwise. It means the inference enable/disable change was rejected server-side.","triggerScenarios":"PATCH /v1/inference/settings fails: org payment/subscription required for the tier (402-style), tier not available on the plan (400/403), session expired (401), or 5xx. 20s timeout because provisioning can be slow.","commonSituations":"Enabling inference without an active subscription; requesting a tier unavailable to the org's plan; admin session expiring between loading status and toggling; server-side provisioning failing (timeout/5xx).","solutions":["Check the surfaced server message; a payment-required message means subscribe first (startSubscribeCheckout).","Retry the toggle after re-authenticating if the error is reauth-required.","Confirm the selected tier is allowed for the org's plan; switch tiers if not.","Refresh status via GET before retrying to avoid toggling against stale state.","On 5xx/timeout, check Den inference provisioning logs."],"exampleFix":"// before\nif (!response.ok) {\n  throw getRequestError(payload, response, `Failed to update inference settings (${response.status}).`);\n}\n// after\nif (!response.ok) {\n  const err = getRequestError(payload, response, `Failed to update inference settings (${response.status}).`);\n  if (getOrgPaymentRequiredError(payload)) throw new Error(\"Subscribe to inference before enabling it.\");\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"const { response, payload } = await requestJson(\"/v1/inference/status\", {}, 10000);\nif (!response.ok) return; // cannot toggle against unknown state\nconst paymentRequired = getOrgPaymentRequiredError(payload);\nif (paymentRequired) { showSubscribePrompt(); return; }","typeGuard":"function isPaymentRequired(p: unknown): boolean { return getOrgPaymentRequiredError(p) !== null; }","tryCatchPattern":"try {\n  await toggleEnabled();\n} catch (error) {\n  if (isReauthRequiredError(error)) { promptReauth(); return; }\n  setStatus((prev) => prev); // revert optimistic switch\n  showToast(error instanceof Error ? error.message : \"Could not update inference settings.\");\n}","preventionTips":["Refresh inference status before toggling to avoid acting on stale data","Revert the optimistic toggle when the PATCH fails","Check subscription/payment-required state before enabling","Use the 20s timeout as-is; provisioning can be slow - show a spinner"],"tags":["http","billing","settings","network"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}