Conversation
NewIdentity asserted identityData["email"] to a string without checking
the type. A phone signup omits the empty email claim (structs omitempty),
so a user-supplied `data.email` that is null or otherwise non-string
reaches identityData and panics with "interface conversion: interface {}
is nil, not string", turning a signup/OTP request into a 500.
Only assign the identity email when the value is actually a string, and
apply the same guard in BeforeUpdate. Adds regression coverage.
Fixes supabase#2268
2 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
NewIdentityininternal/models/identity.goassertedidentityData["email"]to astringwithout checking the type:identityDatais assembled by merging user-supplied signupdatametadata intoprovider.Claims. For a phone signup the email claim is empty andClaimsusesstructs:"email,omitempty", so it is dropped from the map — which lets a user-supplieddata.emailthat isnull(or any non-string) survive intoidentityData["email"]. The unchecked assertion then panics:The panic happens during identity creation, before any SMS is sent, so the request returns a bare
500 unexpected_failureinstead of a meaningful error. This matches the stack trace and the "happens on phone signup / SMS OTP" symptom in the issue.Fix
Only assign the identity email when the value is actually a string, and apply the same guard to the assertion in
BeforeUpdate. A non-string email is ignored (theidentities.emailcolumn is optional), so signup proceeds normally instead of crashing.Testing
Added regression coverage in
internal/models/identity_test.gofor a string email and for non-string values (nil, int, bool, map) that previously panicked.go test ./internal/models/...passes;gofmtandgo vetare clean.Fixes #2268