test(gotrue): model real email_change first-confirmation response in verifyOTP#1468
Merged
spydon merged 1 commit intoJun 25, 2026
Conversation
…verifyOTP test
The secure email change first-confirmation returns a 200 with a
{msg, code} payload and neither a user nor a session. Update the
NullSessionClient mock to use that realistic shape and assert that
verifyOTP returns a null user in addition to a null session.
grdsdev
approved these changes
Jun 25, 2026
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 kind of change does this PR introduce?
Test improvement (verifies an already-correct behavior).
Resolves SDK-1020.
Triage notes
SDK-1020 is an auto-generated parity issue mirroring two
supabase-jsfixes:verifyOtp({type: 'email_change'})first confirmation should return{user: null, session: null}when GoTrue replies200with{msg, code}.signUp()when confirmation is required should return{user: <User>, session: null}when GoTrue returns the bare user (noaccess_token).Both behaviors are already correct in supabase-flutter, because the Dart models are null-safe by design:
Session.fromJsonreturnsnullwhen there is noaccess_token.User.fromJsonreturnsnullwhen there is noid.AuthResponse.fromJsoncomposes the two, so{msg, code}yields{user: null, session: null}and a bare user yields{user: <User>, session: null}.Fix 1 was additionally hardened in #1448 (verifyOTP no longer throws on a null session). Fix 2 is already covered by the existing
signUp() with autoConfirm off with emailtest, which asserts a null session and a non-null user.What does this PR change?
The only gap against the acceptance criteria was that the email_change verifyOTP test used an unrealistic mock body (
{user: {id, email}}) and never asserted the user was null. This PR:NullSessionClientto return the real GoTrue first-confirmation payload ({msg, code}, no user, no session).verifyOTPreturns both a null user and a null session for that shape.No production code changes, no API surface changes, non-breaking.