{"record":{"id":"c132909438d534fe","repo":"different-ai/openwork","slug":"organization-was-created-but-no-slug-was-returned","errorCode":null,"errorMessage":"Organization was created, but no slug was returned.","messagePattern":"Organization was created, but no slug was returned\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/_components/organization-screen.tsx","lineNumber":124,"sourceCode":"    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      }\n\n      router.push(getMarketplaceOnboardingRoute(nextSlug));\n    } catch (err) {\n      setCreateError(err instanceof Error ? err.message : \"Failed to create organization.\");\n      setCreateBusy(false);\n    }\n  }\n\n  function handleSwitch(slug: string) {\n    router.push(getOrgDashboardRoute(slug));","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/_components/organization-screen.tsx#L106-L142","documentation":"organization-screen.tsx throws this when POST /v1/org succeeded (2xx) but the response body either has no `organization` object or that object has no string `slug`. This is a client-side contract check preventing navigation to an org route without a slug.","triggerScenarios":"Server returns 2xx for org creation but the payload shape is wrong: `{}` , `{ organization: null }`, or `{ organization: { name: \"...\" } }` with no `slug` string.","commonSituations":"API version skew (old server without slug in create response); server bug after a rename/migration where the slug column is null; response transformed by middleware that drops fields.","solutions":["Log the raw create-org response to confirm the payload shape","Fix/upgrade the server so POST /v1/org returns `organization.slug`","Verify the org was actually created (it may exist server-side) before retrying to avoid duplicates","Add a server-side test asserting the create response contract"],"exampleFix":"// before\nconst nextSlug = typeof organization?.slug === \"string\" ? organization.slug : null;\nif (!nextSlug) {\n  throw new Error(\"Organization was created, but no slug was returned.\");\n}\n// after\nconst nextSlug = typeof organization?.slug === \"string\" && organization.slug.length > 0 ? organization.slug : slugify(organization?.name ?? trimmed);\nif (!nextSlug) {\n  throw new Error(\"Organization was created, but no slug was returned.\");\n}","handlingStrategy":"type-guard","validationCode":"const payload = await res.json();\nconst slug = (payload as { organization?: { slug?: unknown } })?.organization?.slug;\nif (typeof slug !== \"string\" || slug.length === 0) {\n  console.warn(\"create-org response missing slug\", payload);\n}","typeGuard":"function hasOrgSlug(p: unknown): p is { organization: { slug: string } } {\n  const org = (p as { organization?: { slug?: unknown } } | null)?.organization;\n  return typeof org?.slug === \"string\" && org.slug.length > 0;\n}","tryCatchPattern":"try {\n  const nextSlug = getCreatedOrgSlug(payload);\n  if (!nextSlug) throw new Error(\"Organization was created, but no slug was returned.\");\n} catch (err) {\n  await refreshOrgList(); // org may exist; recover by re-fetching instead of dead-ending\n  showError(\"The organization was created but could not be opened. Reloading your organizations.\");\n}","preventionTips":["Add a server test asserting POST /v1/org always returns organization.slug","After this error, re-fetch the org list — the org usually exists and can be recovered","Generate the slug server-side from a NOT NULL column so it can never be null","Pin API versions between den-web and the Den server to avoid contract drift"],"tags":["http","api-response","den-web","organizations"],"backgroundTag":"api-response-missing-field","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}