{"record":{"id":"500111c99f368b46","repo":"different-ai/openwork","slug":"organization-was-created-but-no-slug-was-returned-500111","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)/dashboard/_providers/org-dashboard-provider.tsx","lineNumber":452,"sourceCode":"        {\n          method: \"POST\",\n          body: JSON.stringify({ name: trimmed }),\n        },\n        12000,\n      );\n\n      if (!response.ok) {\n        throw new Error(getErrorMessage(payload, `Failed to create organization (${response.status}).`));\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      router.push(getOrgDashboardRoute(nextSlug));\n    } finally {\n      setMutationBusy(null);\n    }\n  }\n\n  function switchOrganization(nextSlug: string) {\n    if (isSingleOrgMode) {\n      return;\n    }\n\n    const targetOrg = orgDirectory.find((entry) => entry.slug === nextSlug) ?? null;\n    if (!targetOrg) {\n      return;\n    }\n","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx#L434-L470","documentation":"After a successful create-organization response (2xx), the code extracts payload.organization.slug and throws this error if the slug is missing or not a string. The organization WAS created on the server, but the client cannot navigate to its dashboard because the slug needed for getOrgDashboardRoute is absent — a response-shape contract violation.","triggerScenarios":"Server returns 2xx with a body lacking the organization object (e.g., { ok: true }), an older API version returning a different envelope, or organization.slug null/undefined/non-string in the payload.","commonSituations":"Partial deploy with den-api returning the legacy create-org response shape; proxy intercepting and replacing the JSON body; a future API change renaming slug while den-web is stale.","solutions":["Instead of throwing, recover by reloading the org directory (loadOrgDirectory/refreshOrgData) — the created org (and its slug) will appear there, avoiding a duplicate-create retry.","Log the raw payload to confirm the actual response shape.","Pin den-web and den-api to matching versions; deploy together.","If you control the API, include the full organization object with a string slug in the create response.","Verify with a type guard that payload.organization?.slug is a string before router.push."],"exampleFix":"// before\nif (!nextSlug) {\n  throw new Error(\"Organization was created, but no slug was returned.\");\n}\n// after\nif (!nextSlug) {\n  const orgs = await loadOrgDirectory(); // org exists; find it there\n  const created = orgs[orgs.length - 1];\n  if (created?.slug) router.push(getOrgDashboardRoute(created.slug));\n  return;\n}","handlingStrategy":"fallback","validationCode":"const org = (payload as { organization?: { slug?: unknown } } | null)?.organization;\nconst ok = typeof org?.slug === \"string\" && org.slug.length > 0;\nif (!ok) await refreshOrgData(); // recover via directory instead of throwing","typeGuard":"function hasCreatedOrgSlug(p: unknown): p is { organization: { slug: string } } {\n  const o = p as { organization?: { slug?: unknown } } | null;\n  return !!o && typeof o.organization?.slug === \"string\";\n}","tryCatchPattern":"try {\n  await createOrganization(name);\n} catch (err) {\n  if (err.message === \"Organization was created, but no slug was returned.\") {\n    await refreshOrgData(); // org exists; navigate from directory\n    return;\n  }\n  throw err;\n}","preventionTips":["Never retry create blindly after this error — the org already exists on the server.","Assert the create-response shape in API contract tests.","Keep den-web/den-api in lockstep versions.","Include the full organization object (with string slug) in the create response.","Log the raw payload when the slug is missing to catch envelope drift early."],"tags":["schema","contract-mismatch","create","den-web"],"backgroundTag":"schema-validation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}