Skip to content

fix(deco-sites): avoid duplicate profile insert on service account creation#3176

Merged
guitavano merged 1 commit intomainfrom
fix/deco-sites-service-account-profile-conflict
Apr 24, 2026
Merged

fix(deco-sites): avoid duplicate profile insert on service account creation#3176
guitavano merged 1 commit intomainfrom
fix/deco-sites-service-account-profile-conflict

Conversation

@guitavano
Copy link
Copy Markdown
Contributor

@guitavano guitavano commented Apr 24, 2026

Summary

  • Supabase has a DB trigger that auto-creates a profiles row when a new auth user is created
  • getOrCreateTeamServiceAccount was unconditionally inserting a profile after creating the auth user, hitting a 409 unique constraint violation (profiles_user_id_key) on the first call
  • Now checks if the profile already exists before attempting to insert, making the first call succeed

Test plan

  • Call POST /api/deco-sites/connection for a site whose team has no service account yet — should succeed on the first attempt
  • Call it again for another site in the same team — should reuse the existing service account

🤖 Generated with Claude Code


Summary by cubic

Prevents duplicate profile creation for team service accounts by checking for an existing profiles row before inserting. This removes the 409 unique constraint error and makes the first request succeed.

  • Bug Fixes
    • In getOrCreateTeamServiceAccount, query profiles by user_id and only insert if missing (accounts for Supabase trigger-created rows).
    • POST /api/deco-sites/connection succeeds on first use and reuses the same service account for the team on later calls.

Written for commit ac89f64. Summary will update on new commits.

…eation

Supabase has a DB trigger that auto-creates a profiles row when a new
auth user is created. The explicit INSERT was hitting a unique constraint
violation (profiles_user_id_key) on the first call, causing a 409/500.
Now we check if the profile already exists before attempting to insert.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

Release Options

Suggested: Patch (2.274.1) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.274.1-alpha.1
🎉 Patch 2.274.1
❤️ Minor 2.275.0
🚀 Major 3.0.0

Current version: 2.274.0

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

@guitavano guitavano merged commit 0c2f9a7 into main Apr 24, 2026
15 checks passed
@guitavano guitavano deleted the fix/deco-sites-service-account-profile-conflict branch April 24, 2026 17:13
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.

2 participants