Skip to content

Fix company submission failing with generic server error#391

Open
pontusab wants to merge 1 commit into
mainfrom
fix/upsert-company-create-flow
Open

Fix company submission failing with generic server error#391
pontusab wants to merge 1 commit into
mainfrom
fix/upsert-company-create-flow

Conversation

@pontusab
Copy link
Copy Markdown
Collaborator

@pontusab pontusab commented May 19, 2026

The company form always generates a fresh client-side nanoid, which the upsert action treated as proof of an edit and rejected with a permission error. Treat the request as an edit only when a matching row exists, surface upsert errors as ActionError, and resolve conflicts by id.


Note

Medium Risk
Touches write/permission logic for companies upsert and changes conflict semantics to onConflict: "id", which could affect updates/uniqueness behavior if assumptions differ from the DB schema.

Overview
Fixes company submission/upsert to avoid treating any provided id as an edit: it now checks whether a companies row actually exists and only blocks when the existing row is owned by another user.

Changes the Supabase upsert to resolve conflicts by id (instead of slug) and surfaces permission/upsert failures as ActionError so users see specific messages rather than a generic server error.

Reviewed by Cursor Bugbot for commit 52b7daf. Bugbot is set up for automated code reviews on this repo. Configure here.

The company form always generates a fresh client-side nanoid, which the
upsert action treated as proof of an edit and rejected with a permission
error. Treat the request as an edit only when a matching row exists,
surface upsert errors as ActionError, and resolve conflicts by id.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cursor-directory Ready Ready Preview, Comment May 19, 2026 9:26am

Request Review

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