Skip to content

test(gotrue): model real email_change first-confirmation response in verifyOTP#1468

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1020-parityauth-verifyotp-for-email_change-returns-null
Jun 25, 2026
Merged

test(gotrue): model real email_change first-confirmation response in verifyOTP#1468
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1020-parityauth-verifyotp-for-email_change-returns-null

Conversation

@spydon

@spydon spydon commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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-js fixes:

  1. verifyOtp({type: 'email_change'}) first confirmation should return {user: null, session: null} when GoTrue replies 200 with {msg, code}.
  2. signUp() when confirmation is required should return {user: <User>, session: null} when GoTrue returns the bare user (no access_token).

Both behaviors are already correct in supabase-flutter, because the Dart models are null-safe by design:

  • Session.fromJson returns null when there is no access_token.
  • User.fromJson returns null when there is no id.
  • AuthResponse.fromJson composes 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 email test, 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:

  • Updates NullSessionClient to return the real GoTrue first-confirmation payload ({msg, code}, no user, no session).
  • Asserts verifyOTP returns both a null user and a null session for that shape.

No production code changes, no API surface changes, non-breaking.

…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.
@spydon spydon requested a review from a team as a code owner June 25, 2026 09:36
@github-actions github-actions Bot added the auth This issue or pull request is related to authentication label Jun 25, 2026
@spydon spydon merged commit 296971d into main Jun 25, 2026
28 checks passed
@spydon spydon deleted the lukasklingsbo/sdk-1020-parityauth-verifyotp-for-email_change-returns-null branch June 25, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth This issue or pull request is related to authentication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants