Skip to content

Keep a refused participant's address out of the logs - #1139

Open
richshaw wants to merge 1 commit into
mainfrom
claude/issue-1134-send-error-addresses
Open

richshaw wants to merge 1 commit into
mainfrom
claude/issue-1134-send-error-addresses

Conversation

@richshaw

Copy link
Copy Markdown
Owner

Fixes #1134.

Session: https://claude.ai/code/session_016YZ9STgsc9rELBtYrsAhSy

The problem

When the mail server or Resend refuses a participant's address, the confirmation, reminder or time-changed email fails with the transport's raw error. That error carries the address: nodemailer puts it in rejected and response, and Resend's response body names it. The confirmation's catch and the worker's queues log the error whole. #709 fixed this for the sign-in email only.

The fix

  • src/email/send-error.ts now holds describeSendError, toSendFailure and the scrub helpers, moved unchanged from src/auth/magic-link-send.ts, which imports them from there. Only the doc comment on toSendFailure changed, to say who uses it now.
  • src/email/send.ts: the three senders go through one local send(message). It turns a rejection into toSendFailure(reason), so it keeps the message (addresses blanked), code, responseCode, and the cause's message and code. It still rejects, so pg-boss still retries reminderSend and slotChangeSend. The log calls themselves don't change.
  • The same scrub as the sign-in path. It also blanks URL query strings and six-digit codes in the mail server's text. That's harmless here, and keeping one cleaner is what the issue asks for.
  • CHANGELOG entry under Fixed. The privacy page already says logs don't include email addresses, so it needs no change.

Tests

  • src/email/send.test.ts covers each of the three senders, with a nodemailer-style refusal and with a real ResendTransport against a stubbed 422 body. Each one rejects with no pat@example.com in the error or in the line the production logger writes, and keeps its code. All six of those tests failed before the fix.
  • src/email/notify.db.test.ts runs notifyCommitmentCreated with a refusing transport and the production logger options. The "confirmation email failed" line keeps EENVELOPE and has no address. It fails on main's send.ts.
  • The sign-in send tests pass unchanged.
  • Ran and passed: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test (3894 passed) and pnpm test:db (914 passed).

Generated by Claude Code

A confirmation, reminder or time-changed email the mail server or Resend
refuses now rejects with the same cleaned error the sign-in email has used
since #709: its message with addresses blanked, its code and responseCode,
and its cause's message and code. The transport's own error carried the
address in nodemailer's rejected and response, or in Resend's response
body, and the confirmation's catch and the worker's queues logged it whole.

The cleaner moves from src/auth/magic-link-send.ts to src/email/send-error.ts
so both paths share it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9STgsc9rELBtYrsAhSy
@richshaw richshaw added pipeline:tophat pipeline:working A session is working on it right now and removed pipeline:working A session is working on it right now labels Nov 26, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Tophat: passed

See it: https://claude.ai/artifact/MHWWRLV8mrRBMSbMZvd1uC
What changes for people: nothing on any screen or in any email. When a mail server refuses a participant's address, the server and worker logs now say why without naming the address, as the sign-in email already did.

Check Result What I saw
Base: confirmation and reminder to a refused address ✅ Bug reproduced. A local SMTP server answering 550 5.1.1 <refused@example.com> put the address in the web log 6 times and in the worker log 18 times (message, response, rejected, rejectedErrors).
Head: confirmation to a refused address ✅ confirmation email failed shows the message with <[email]>, plus EENVELOPE and 550. The sign-up still returned 200.
Head: reminder and time-changed email to a refused address ✅ Both logged <[email]>, EENVELOPE and 550. pg-boss still retried them (retry_count 2, then failed).
Head: the same three emails to a good address ✅ All three reached the mail server and were recorded (commitment.confirmation_sent, reminder.sent, slot.change_sent).
Head: sign-in email (the code that moved) ✅ A refused address logged auth: error with <[email]>, EENVELOPE and 550. A good address was delivered and sent the browser to verify-request.
All head logs ✅ @example.com appears 0 times in the web and worker logs.

Not checked: Resend's refusal in the running app, because that needs a Resend account; the PR's unit tests cover it with a stubbed 422 body. The participant pages in a browser: headless Chromium rendered blank pages in this container, so the sign-ups went through the public API. This PR changes no screen.

Why it waits for you: it touches src/auth/magic-link-send.ts (high risk: sign-in code). The change there is a move of the clean-up helpers into src/email/send-error.ts.

Ran 6ce2539 against bc6daff locally with pnpm dev, pnpm worker, a local SMTP server that refuses refused* addresses, and made-up data. https://claude.ai/code/session_016YZ9SRnNi6nAujsZxLYR7r


Generated by Claude Code

@richshaw richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:tophat pipeline:working A session is working on it right now labels Nov 26, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review: passed (round 1)

The cleaner moves into src/email/send-error.ts unchanged, apart from its doc comment. magic-link-send.ts imports it from there. The three participant sends go through one send() that still rejects, with toSendFailure(reason). No caller reads the error's shape, so retries and logging work as before. Every item in #1134's outline and "Done when" is done.

Blocking (0)
Optional (3):

  • send-error.ts:75: the address regex is quadratic on a long run with no @, and resend.ts:27 puts the whole response body in the message. Capping the scrubbed text at a few KB would fix it.
  • scrub also blanks six-digit numbers in participant failures (a message size, for example). It's harmless.
  • CHANGELOG.md:172 leaves out that the first cause's message and code are kept too.

(The console transport logging to was already there before this PR and is a dev transport.)
Earlier threads: none
Checks: CI green on 6ce2539 (lint-type-test, e2e, CodeQL). The tophat passed on this SHA. I ran code-review at high effort.

Waits for the owner because it touches src/auth/magic-link-send.ts, which is high-risk. The change there only moves the helpers. Card: https://claude.ai/artifact/MHWWRLV8mrRBMSbMZvd1uC

https://claude.ai/code/session_016YZ9SVwmrsoS91wZsh4uBA


Generated by Claude Code

@richshaw richshaw added pipeline:owner Passed; waits for the owner (UX or high-risk) and removed pipeline:review pipeline:working A session is working on it right now labels Nov 26, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipeline:owner Passed; waits for the owner (UX or high-risk)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A participant email the mail server refuses puts the participant's address in the logs

2 participants