Skip to content

fix: 409 for duplicate email connections#1586

Merged
tyler-dane merged 8 commits intomainfrom
fix/409-already-connected
Mar 30, 2026
Merged

fix: 409 for duplicate email connections#1586
tyler-dane merged 8 commits intomainfrom
fix/409-already-connected

Conversation

@tyler-dane
Copy link
Copy Markdown
Contributor

@tyler-dane tyler-dane commented Mar 30, 2026

Note

Medium Risk
Touches authentication/session and account-linking paths (canonical user resolution and session replacement), which can affect login behavior and user mapping if incorrect. Changes are covered by expanded unit tests but still impact critical auth flows.

Overview
Fixes duplicate-account edge cases by introducing a canonical Compass user lookup (preferring googleUserId, falling back to normalized email) and reusing that user across Google OAuth and email/password auth flows.

Backend errors now support stable machine-readable codes: BaseError carries an optional code, the centralized error handler includes it in the client payload, and Google connect adds a new 409 case (GOOGLE_CONNECT_EMAIL_MISMATCH) plus a coded GOOGLE_ACCOUNT_ALREADY_CONNECTED conflict.

Web adds shared Zod error schemas in core, generic parseApiError(...) plus parseGoogleConnectError(...), and updates the Google connect hook to show the server-provided message and keep the connect action available on typed failures; docs are updated to codify this shared error-contract pattern.

Written by Cursor Bugbot for commit 4648306. This will update automatically on new commits. Configure here.

@tyler-dane tyler-dane changed the title Fix/409 already connected Fix: 409 for duplicate email connections Mar 30, 2026
Comment thread packages/backend/src/common/helpers/email.util.ts
@tyler-dane tyler-dane changed the title Fix: 409 for duplicate email connections fix: 409 for duplicate email connections Mar 30, 2026
Comment thread packages/backend/src/user/services/user.service.ts
Comment thread packages/web/src/common/apis/compass.api.util.ts Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Comment thread packages/backend/src/user/services/user.service.ts
@tyler-dane tyler-dane merged commit 982383f into main Mar 30, 2026
9 checks passed
@tyler-dane tyler-dane deleted the fix/409-already-connected branch March 30, 2026 11:16
tyler-dane added a commit to Muhammad-Nur-Alamsyah-Anwar/compass that referenced this pull request Mar 30, 2026
* feat: consolidate emails upon duplicate to handle 409 conflicts

* refactor: harden typing for google error handling

* chore: reuse normalizeEmail util

* fix: reduce extra user query

* chore: remove dead error handling code

* refactor: reuse findCanonicalCompassUser

* fix(backend): update google auth mocks
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