{"record":{"id":"c1e89a3c69122f55","repo":"different-ai/openwork","slug":"failed-to-create-organization","errorCode":null,"errorMessage":"Failed to create organization.","messagePattern":"Failed to create organization\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/_components/organization-screen.tsx","lineNumber":114,"sourceCode":"    e.preventDefault();\n    if (isSingleOrgMode) {\n      setCreateError(\"This deployment uses one managed organization.\");\n      return;\n    }\n\n    const trimmed = createName.trim();\n    if (!trimmed) return;\n\n    setCreateBusy(true);\n    setCreateError(null);\n    try {\n      const { response, payload } = await requestJson(\"/v1/org\", {\n        method: \"POST\",\n        body: JSON.stringify({ name: trimmed }),\n      });\n\n      if (!response.ok) {\n        throw new Error(getErrorMessage(payload, \"Failed to create organization.\"));\n      }\n\n      const organization =\n        typeof payload === \"object\" && payload && \"organization\" in payload && payload.organization && typeof payload.organization === \"object\"\n          ? (payload.organization as { slug?: unknown })\n          : null;\n      const nextSlug = typeof organization?.slug === \"string\" ? organization.slug : null;\n\n      if (!nextSlug) {\n        throw new Error(\"Organization was created, but no slug was returned.\");\n      }\n\n      const pendingIntent = normalizeAuthIntentParam(window.sessionStorage.getItem(PENDING_AUTH_INTENT_STORAGE_KEY));\n      if (pendingIntent === \"models\") {\n        window.sessionStorage.removeItem(PENDING_AUTH_INTENT_STORAGE_KEY);\n        router.push(getInferenceRoute(nextSlug));\n        return;\n      }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/_components/organization-screen.tsx#L96-L132","documentation":"organization-screen.tsx throws this as the fallback message when `POST /v1/org` returns a non-ok status without a parseable error payload. The organization was not created, but the API gave no specific reason.","triggerScenarios":"`requestJson(\"/v1/org\", { method: \"POST\", body: ... })` responds with response.ok === false and no message in the payload — e.g. 409 duplicate name, 401 unauthorized, or 422 validation failure with empty body.","commonSituations":"User submits an org name that already exists (409); session expired mid-flow (401); server-side validation rejects the name with a non-JSON body; rate limiting (429) with empty response.","solutions":["Check the response status code in the network tab to identify the real cause","Retry with a different organization name if it is a duplicate (409)","Re-authenticate if the status is 401","Have the API return a JSON error body so getErrorMessage can surface the server's message"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const name = trimmed;\nif (!name || name.length > 64) {\n  setError(\"Organization name must be 1-64 characters.\");\n  return;\n}","typeGuard":"function isOrgPayload(p: unknown): p is { organization: { slug: string } } {\n  return typeof p === \"object\" && p !== null && \"organization\" in p && typeof (p as { organization: unknown }).organization === \"object\";\n}","tryCatchPattern":"try {\n  const { response, payload } = await requestJson(\"/v1/org\", { method: \"POST\", body: JSON.stringify({ name }) });\n  if (!response.ok) throw new Error(getErrorMessage(payload, \"Failed to create organization.\"));\n} catch (err) {\n  if (isDuplicateOrgError(err)) setError(\"That organization name is taken. Try another.\");\n  else setError(\"Failed to create organization. Please try again.\");\n}","preventionTips":["Validate org name format/length client-side before POSTing","Handle 409 duplicates with a friendly 'name taken' message","Keep the session fresh so 401s are rare","Return structured JSON errors from the API with a message field"],"tags":["http","fetch","den-web","organizations","create"],"backgroundTag":"api-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}