Skip to content

fix(e2e): widen password reset link extraction for Supabase format variance (PP-q9r)#1279

Open
timothyfroehlich wants to merge 4 commits intomainfrom
fix/e2e-password-reset-PP-q9r
Open

fix(e2e): widen password reset link extraction for Supabase format variance (PP-q9r)#1279
timothyfroehlich wants to merge 4 commits intomainfrom
fix/e2e-password-reset-PP-q9r

Conversation

@timothyfroehlich
Copy link
Copy Markdown
Owner

Summary

  • Fixes email-and-notifications.spec.ts:717 consistently failing in CI with "Password reset link not found in email body"
  • PASSWORD_RESET_LINK_REGEX only matched href="..." patterns in HTML; newer GoTrue versions used via supabase/setup-cli@version:latest in CI may produce different email formats
  • Added two additional fallback extraction strategies and comprehensive diagnostics logging

What changed

e2e/support/mailpit.tsgetPasswordResetLink

Before: single PASSWORD_RESET_LINK_REGEX matching only href attributes in HTML body.

After: three strategies tried in order:

  1. Original href="...auth/v1/verify..." regex in HTML (strategy 1 — handles current format)
  2. Bare URL containing /auth/v1/verify anywhere in HTML or plain-text body (strategy 2 — handles plain-text emails and single-quote href variants)
  3. Direct /auth/callback URL (strategy 3 — handles newer Supabase formats that embed the callback URL directly in the email)

On final failure, logs message ID, subject, recipients, date, and full HTML + text bodies to console.error so future CI failures are immediately diagnosable.

Root cause confidence

The exact email format used in CI could not be directly observed (CI-only failure). Evidence:

  • Test passes locally with GoTrue v2.188.1
  • CI uses version: latest which pulls newer GoTrue; format variance between local cached images and CI latest is the most likely cause
  • The diagnostic logging added here will reveal the exact format in the next CI run if strategy 1 still misses it (strategies 2 and 3 provide defense-in-depth)

Test plan

  • pnpm exec playwright test e2e/full/email-and-notifications.spec.ts -g "password reset flow" --project=chromium --repeat-each=3 passes 3/3 locally
  • pnpm run check clean (1013 unit tests pass, typecheck clean, lint clean)
  • CI E2E Full Tests (Chromium) green — this is the primary acceptance gate

Fixes #PP-q9r

🤖 Generated with Claude Code

…abase email formats (PP-q9r)

The PASSWORD_RESET_LINK_REGEX was only matching href attributes in HTML
containing /auth/v1/verify. Newer GoTrue versions (used in CI via
supabase/setup-cli@version:latest) may use a different email link format —
either a plain-text URL, a token_hash variant, or a direct /auth/callback URL.

Add two additional extraction strategies after the original href regex:
- Strategy 2: bare URL with /auth/v1/verify (covers plain-text and
  single-quote href variants)
- Strategy 3: direct /auth/callback URL (covers newer Supabase formats that
  embed the callback URL directly in the email)

Also log the full message body (HTML + Text), headers, and ID to console.error
when all strategies fail, so future CI flakes are immediately diagnosable
without having to grep through hundreds of lines of webserver logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 5, 2026 00:59
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pin-point Ready Ready Preview, Comment May 5, 2026 8:26pm

@supabase
Copy link
Copy Markdown

supabase Bot commented May 5, 2026

Updates to Preview Branch (fix/e2e-password-reset-PP-q9r) ↗︎

Deployments Status Updated
Database Tue, 05 May 2026 20:21:28 UTC
Services Tue, 05 May 2026 20:21:28 UTC
APIs Tue, 05 May 2026 20:21:28 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Tue, 05 May 2026 20:21:29 UTC
Migrations Tue, 05 May 2026 20:21:29 UTC
Seeding Tue, 05 May 2026 20:21:29 UTC
Edge Functions Tue, 05 May 2026 20:21:29 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the resilience of the E2E password reset flow by broadening how the test helper extracts the Supabase password reset URL from Mailpit emails, accounting for email format differences across GoTrue/Supabase versions (notably in CI).

Changes:

  • Expanded getPasswordResetLink() to try multiple extraction strategies (/auth/v1/verify via href, then any verify URL, then /auth/callback).
  • Added failure diagnostics that print message metadata and bodies to help debug CI-only flakes.

Comment thread e2e/support/mailpit.ts Outdated
Comment thread e2e/support/mailpit.ts Outdated
…redact tokens in logs (PP-q9r)

Two improvements from code review:

1. Strategy 2 and 3 now search HTML and text bodies independently (using ??
   rather than htmlBody||textBody), so a non-empty HTML part no longer hides a
   link that appears only in the plain-text body.

2. The failure diagnostic log now redacts one-time token values (token=,
   token_hash=, code= query params are replaced with [REDACTED]) before
   printing, preventing accidental secret leakage into CI logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…PP-q9r)

Iteration 2 — actual CI email format diagnosed via the iteration 1
diagnostics. Current Supabase GoTrue serves password reset links from
/verify (no /auth/v1/ prefix), and the redirect_to /auth/callback URL
appears only URL-encoded as a query parameter.

Updated all three strategies:
- Strategy 1 (href in HTML): now matches /verify?...type=recovery
- Strategy 2 (bare URL): now matches /verify?...type=recovery in either body
- Strategy 3 (callback URL): kept unchanged as defensive coverage for any
  future format where the callback URL appears directly

type=recovery disambiguates from signup/invite emails that also hit /verify
but with type=signup or type=invite.

Verified: 3/3 local Chromium runs pass for the password reset spec.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread e2e/support/mailpit.ts
@timothyfroehlich timothyfroehlich added the ready-for-review PR passed CI and has no unresolved review comments label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review PR passed CI and has no unresolved review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants