fix: org creation#897
Conversation
How to use the Graphite Merge QueueAdd the label Main to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Claude finished @MaheshtheDev's task in 58s —— View job Review Complete
Summary: This is a clean bug fix that correctly accesses the organization slug from the Better Auth response structure ( Score: 10/10 |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-mcp | 703ebf7 | May 03 2026, 12:24 AM |
Merge activity
|
There was a problem hiding this comment.
Overview: Fixes org creation by correctly accessing the slug from the Better Auth response structure (result.data?.slug instead of newOrg.slug).
Issues found: None — this looks good to ship.
The fix correctly handles the Better Auth API response format which wraps the organization data in a data property. The fallback to the locally generated slug provides resilience if the API response is incomplete. The change from ?? to || for the name is also appropriate to handle empty string edge cases.
Score: 10/10
5459a88 to
703ebf7
Compare
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | 703ebf7 | Commit Preview URL | May 03 2026, 12:26 AM |
| const result = await authClient.organization.create({ | ||
| name, | ||
| slug: generateOrgSlug(name), | ||
| slug, | ||
| metadata: { signupSource: "consumer" }, | ||
| }) | ||
| await setActiveOrg(newOrg.slug) | ||
| await setActiveOrg(result.data?.slug ?? slug) |
There was a problem hiding this comment.
[P2] organization.create errors silently fall back to a potentially invalid slug.
Since authClient is configured without fetchOptions.throw, Better Auth client calls resolve as { data, error } on HTTP errors rather than throwing. With result.data?.slug ?? slug, any create failure (auth/session issues, org limits, slug conflict) falls back to the locally generated slug and calls setActiveOrg with a slug that may not exist on the server. Onboarding then continues as if setup succeeded.
Suggested fix -- check the result before activating:
const result = await authClient.organization.create({
name,
slug,
metadata: { signupSource: "consumer" },
})
if (result.error || !result.data?.slug) {
throw new Error(result.error?.message ?? "Failed to create organization")
}
await setActiveOrg(result.data.slug)This avoids proceeding with a non-existent org.
Testing ResultsThe fix was verified at three independent levels: 1. TypeScript Type-Check
2. Logic Simulation
3. End-to-End Live TestAuthenticated as a user with empty-string name and 0 organizations -- the exact edge case this PR fixes.
API verification: 1 org created, named from email fallback ( Screenshots: Recording: Follow-up: Same bug exists in old onboarding path
Attached Images and Videos |





No description provided.