different-ai/openwork · error
Organization was created, but no slug was returned.
Error message
Organization was created, but no slug was returned.
What it means
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.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx:452
{
method: "POST",
body: JSON.stringify({ name: trimmed }),
},
12000,
);
if (!response.ok) {
throw new Error(getErrorMessage(payload, `Failed to create organization (${response.status}).`));
}
const organization =
typeof payload === "object" && payload && "organization" in payload && payload.organization && typeof payload.organization === "object"
? payload.organization as { slug?: unknown }
: null;
const nextSlug = typeof organization?.slug === "string" ? organization.slug : null;
if (!nextSlug) {
throw new Error("Organization was created, but no slug was returned.");
}
router.push(getOrgDashboardRoute(nextSlug));
} finally {
setMutationBusy(null);
}
}
function switchOrganization(nextSlug: string) {
if (isSingleOrgMode) {
return;
}
const targetOrg = orgDirectory.find((entry) => entry.slug === nextSlug) ?? null;
if (!targetOrg) {
return;
}
View on GitHub (pinned to 2b7df46e8a)
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.
Example fix
// before
if (!nextSlug) {
throw new Error("Organization was created, but no slug was returned.");
}
// after
if (!nextSlug) {
const orgs = await loadOrgDirectory(); // org exists; find it there
const created = orgs[orgs.length - 1];
if (created?.slug) router.push(getOrgDashboardRoute(created.slug));
return;
} Defensive patterns
Strategy: fallback
Validate before calling
const org = (payload as { organization?: { slug?: unknown } } | null)?.organization;
const ok = typeof org?.slug === "string" && org.slug.length > 0;
if (!ok) await refreshOrgData(); // recover via directory instead of throwing Type guard
function hasCreatedOrgSlug(p: unknown): p is { organization: { slug: string } } {
const o = p as { organization?: { slug?: unknown } } | null;
return !!o && typeof o.organization?.slug === "string";
} Try / catch
try {
await createOrganization(name);
} catch (err) {
if (err.message === "Organization was created, but no slug was returned.") {
await refreshOrgData(); // org exists; navigate from directory
return;
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Organization context response was incomplete.
- Failed to create organization.
- Failed to create organization (${response.status}).
- Invalid cloud provider sync response.
- Invalid cloud provider sync status response.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/500111c99f368b46.
Report an issue: GitHub.