Skip to content

fix: resolve 500 error on onboarding due to OAuth ID mismatch and Neon cold start (#428) - #429

Open
aryansondharva wants to merge 2 commits into
LarytheLord:mainfrom
aryansondharva:fix/onboarding-500-error
Open

fix: resolve 500 error on onboarding due to OAuth ID mismatch and Neon cold start (#428)#429
aryansondharva wants to merge 2 commits into
LarytheLord:mainfrom
aryansondharva:fix/onboarding-500-error

Conversation

@aryansondharva

@aryansondharva aryansondharva commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #428

Quest Reference

Copilot AI review requested due to automatic review settings July 9, 2026 14:50
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@aryansondharva is attempting to deploy a commit to the larythelord's projects Team on Vercel.

A member of the Team first needs to authorize it.

@aryansondharva aryansondharva changed the title fix: resolve 500 error on onboarding due to OAuth ID mismatch and Neo… fix: resolve 500 error on onboarding due to OAuth ID mismatch and Neon cold start (#428) Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses production 500s during onboarding by ensuring authenticated sessions use the correct PostgreSQL UUID for OAuth users and by adding retry protection for Neon scale-to-zero cold starts on the onboarding API route.

Changes:

  • Update NextAuth jwt callback to resolve OAuth users to the correct DB UUID (and related fields) during sign-in.
  • Wrap onboarding GET and POST database operations with withDbRetry() and switch onboarding persistence to an upsert.
  • Add/adjust onboarding API route tests with a withDbRetry mock.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/auth.ts Adjusts JWT token hydration for OAuth sign-ins to prevent non-UUID IDs from reaching downstream DB writes.
app/api/user/onboarding/route.ts Adds withDbRetry around onboarding DB calls and uses upsert to handle missing profiles.
tests/api/onboarding.test.ts Adds onboarding route tests and mocks withDbRetry to keep tests deterministic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/auth.ts Outdated
Comment on lines +192 to +201
} else {
token.id = user.id;
}
} catch (error) {
console.error('[Auth] jwt database lookup failed:', error);
token.id = user.id;
}
} else {
token.id = user.id;
}
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.

[BUG] : Onboarding fails with 500 Internal Server Error on /api/user/onboarding

2 participants