AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

GoTrue Identity Linking Returns 500 When Merging Apple Private Relay And Primary Email Accounts

A 500 error occurs during the /auth/v1/token exchange when a user attempts to link an identity whose email is already associated with a different user account. This is common when a user first signs up with Apple using Hide My Email (creating a private relay address) and later signs up or tries to link a Google/email identity with their primary email. The linking endpoint treats the email conflict as a fatal error instead of merging the accounts.

highConfidence 60%GoTrueStorage@supabase/supabase-js

Origin Analysis

The GoTrue identity linking handler checks if the email of the new identity already belongs to another user. If it does, it returns an internal server error ('Multiple accounts with the same email address detected') without attempting to reconcile or merge the conflicting accounts. This design fails to handle legitimate cases where the same person has separate accounts due to Apple private relay email obfuscation.
1. Create user A via Sign in with Apple using Hide My Email; the account receives a private relay email (e.g., anon@privaterelay.appleid.com) and is assigned user_id_1. 2. Create user B via Sign in with Google or email/password using the primary email (e.g., user@gmail.com); this creates user_id_2. 3. While authenticated as user A (user_id_1), call POST /auth/v1/token with grant_type=id_token and provider=google to link the Google identity. 4. The server returns HTTP 500 with the error 'Multiple accounts with the same email address detected' because email user@gmail.com is already owned by user_id_2.

Fixing Code Block

Edge Case Audit

Merging accounts can cause data loss if the duplicate user has application-specific data referencing its user_id; foreign key constraints may also block the deletion. The merge assumes no conflicting identities with the same provider and subject; if both users have an identity for the same provider, the reassignment will violate the unique constraint on (provider, id). Reverting a merge is not possible without a backup. It is strongly recommended to run this logic in a transaction, test on a staging environment, and consider restricting automatic merging to scenarios where the current user has explicitly initiated the linking and both emails are verified.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state