Skip to content

Fix signup application user creation - #6

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-cc2b
Closed

Fix signup application user creation#6
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-cc2b

Conversation

@cursor

@cursor cursor Bot commented Jun 9, 2026

Copy link
Copy Markdown

Bug and impact

Successful /auth/signup calls created a Supabase auth identity but never inserted the corresponding users row. Newly signed-up users could receive tokens, but protected app APIs such as /users/me, preferences, allergens, meal logs, and account deletion would fail with USER_NOT_FOUND or FK errors.

Root cause

AuthService.signUp returned success immediately after Supabase signup and only started ML warmup. The backend uses Supabase user IDs as primary keys in the local Prisma users table, but signup never persisted that local row.

Fix

  • Create the local prisma.user row with the Supabase user ID, email, and display name before returning signup success.
  • If local profile creation fails, roll back the newly-created Supabase auth user and return SIGNUP_PROFILE_FAILED instead of leaving an orphaned unusable auth identity.
  • Keep ML warmup after the local user row is successfully created.
  • Added regression coverage for successful local user creation and rollback on DB failure.

Validation

  • pnpm --filter @snacktrack/backend test -- tests/auth.test.ts passes (2 tests).
  • Backend build passes with test env vars: pnpm --filter @snacktrack/backend build.
  • Full backend unit suite after setup passes 48/49 tests; the remaining existing tests/health.test.ts failure is due to the health route checking ML health while the legacy health test only mocks DB/Redis, unrelated to this signup change.
Open in Web View Automation 

Co-authored-by: Vasanth Panuganti <vpanuga2@asu.edu>
@vasanthpanuganti
vasanthpanuganti deleted the cursor/critical-bug-investigation-cc2b branch June 11, 2026 05:53
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