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
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.
Source
Thrown at ee/apps/den-web/app/(den)/_components/organization-screen.tsx:124
setCreateError(null);
try {
const { response, payload } = await requestJson("/v1/org", {
method: "POST",
body: JSON.stringify({ name: trimmed }),
});
if (!response.ok) {
throw new Error(getErrorMessage(payload, "Failed to create organization."));
}
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.");
}
const pendingIntent = normalizeAuthIntentParam(window.sessionStorage.getItem(PENDING_AUTH_INTENT_STORAGE_KEY));
if (pendingIntent === "models") {
window.sessionStorage.removeItem(PENDING_AUTH_INTENT_STORAGE_KEY);
router.push(getInferenceRoute(nextSlug));
return;
}
router.push(getMarketplaceOnboardingRoute(nextSlug));
} catch (err) {
setCreateError(err instanceof Error ? err.message : "Failed to create organization.");
setCreateBusy(false);
}
}
function handleSwitch(slug: string) {
router.push(getOrgDashboardRoute(slug));View on GitHub (pinned to 2b7df46e8a)
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
Example fix
// before
const nextSlug = typeof organization?.slug === "string" ? organization.slug : null;
if (!nextSlug) {
throw new Error("Organization was created, but no slug was returned.");
}
// after
const nextSlug = typeof organization?.slug === "string" && organization.slug.length > 0 ? organization.slug : slugify(organization?.name ?? trimmed);
if (!nextSlug) {
throw new Error("Organization was created, but no slug was returned.");
} Defensive patterns
Strategy: type-guard
Validate before calling
const payload = await res.json();
const slug = (payload as { organization?: { slug?: unknown } })?.organization?.slug;
if (typeof slug !== "string" || slug.length === 0) {
console.warn("create-org response missing slug", payload);
} Type guard
function hasOrgSlug(p: unknown): p is { organization: { slug: string } } {
const org = (p as { organization?: { slug?: unknown } } | null)?.organization;
return typeof org?.slug === "string" && org.slug.length > 0;
} Try / catch
try {
const nextSlug = getCreatedOrgSlug(payload);
if (!nextSlug) throw new Error("Organization was created, but no slug was returned.");
} catch (err) {
await refreshOrgList(); // org may exist; recover by re-fetching instead of dead-ending
showError("The organization was created but could not be opened. Reloading your organizations.");
} Prevention
- 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
When it happens
Trigger: Server returns 2xx for org creation but the payload shape is wrong: `{}` , `{ organization: null }`, or `{ organization: { name: "..." } }` with no `slug` string.
Common situations: 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.
Related errors
- This install link returned incomplete setup details.
- Failed to load organizations.
- Failed to create organization.
- No OpenWork link was returned.
- Could not prepare an OpenWork link (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/c132909438d534fe.
Report an issue: GitHub.