Skip to content

TOTP enrollment returns 500 for phone-only users (empty TOTP account name) #2872

Open

Description

@emiliosandoval4

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Enrolling a TOTP factor fails with HTTP 500 (unexpected_failure) for users
who signed up with a phone number and have no email address.

enrollTOTPFactor in internal/api/mfa.go passes user.GetEmail() as the
AccountName to totp.Generate. For a phone-only user that string is empty,
github.com/pquerna/otp rejects it (AccountName must be set), and the
handler returns QRCodeGenerationErrorMessage as an internal server error.

To Reproduce

  1. Enable phone sign-in (SMS OTP) and TOTP MFA enrollment.
  2. Sign in with a phone number only (the user has no email).
  3. With that AAL1 session, enroll a TOTP factor:
    await supabase.auth.mfa.enroll({ factorType: 'totp' })
  4. The request fails with HTTP 500 and no factor is created.

Reproduced with the Supabase CLI 2.120.0 local stack (auth v2.197.0). The same
code is still on master (internal/api/mfa.go line 289 at ce9a8ee).

Expected behavior

Phone-only users can enroll TOTP. When the user has no email, the account name
shown in authenticator apps falls back to the phone number (or another stable
identifier).

Screenshots

N/A.

System information

  • OS: Ubuntu 24.04 (CI) and macOS
  • Version of supabase-js: 2.117.3
  • Version of Node.js: 24
  • Supabase CLI: 2.120.0 (auth v2.197.0)

Additional context

Apps that use the phone number as the only identity and require TOTP as the
second factor cannot offer TOTP at all today. Phone-first sign-in is common in
regions where email is not the primary identifier.

I have a small fix with a regression test and will open a PR referencing this
issue.

Activity

  1. montjeffrey commented on Nov 27, 2026

    @montjeffrey

    Reproduced on current master (0725a1d): a phone-only user gets 500 "Error generating QR Code" on POST /factors with factor_type: totp, and the server logs AccountName must be set. A Sign in with Solana user (no email or phone either) gets the same 500. #2873 fixes both when merged on 0725a1d. I put the details on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions