Skip to content

fix(api): enrol the dev session user in the workspace - #194

Open
phanlemanh wants to merge 1 commit into
trycompai:mainfrom
phanlemanh:fix/dev-session-workspace-membership
Open

fix(api): enrol the dev session user in the workspace#194
phanlemanh wants to merge 1 commit into
trycompai:mainfrom
phanlemanh:fix/dev-session-workspace-membership

Conversation

@phanlemanh

@phanlemanh phanlemanh commented Aug 31, 2026

Copy link
Copy Markdown

bun run dev:session me@example.com mints a session that the app then rejects with
"You are not a member of this workspace." — the connections page 500s on it, and so
does anything else workspace-scoped.

The script writes the session row straight through Prisma, so better-auth's
session.create.before hook never runs, and that hook is what calls
ensureWorkspaceMembership. A brand-new dev user therefore never gets a member row.
It only looks like it works on a workspace that still has zero members, where the
backfill branch enrols everyone who already exists.

Two lines: call the same helper the hook calls, and carry activeOrganizationId the
same way it does.


Summary by cubic

Fixes dev sessions so bun run dev:session mints sessions the app accepts. The script wrote session rows directly through Prisma, skipping the session.create.before hook that calls ensureWorkspaceMembership, so new dev users were never enrolled in a workspace and workspace-scoped calls rejected them with "You are not a member of this workspace." The script now calls the same helper and sets activeOrganizationId the same way the hook does.

Written for commit 1c47c66. Summary will update on new commits.

Review in cubic

dev-session writes the session row straight through Prisma, so
better-auth's session.create.before hook never runs and the user never
gets a member row. Every workspace-scoped call then answers 'You are not
a member of this workspace' — the connections page 500s on it. Call the
same helper the hook calls, and carry activeOrganizationId the way it
does.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@phanlemanh is attempting to deploy a commit to the Comp AI - PoC Team on Vercel.

A member of the Team first needs to authorize it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant