Repository navigation
Conversation
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
Tophat: passedSee it: https://claude.ai/artifact/MHWWRLV8mrRBMSbMZvd1uC
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 Ran 6ce2539 against bc6daff locally with Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
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@, andresend.ts:27puts the whole response body in the message. Capping the scrubbed text at a few KB would fix it.scrubalso blanks six-digit numbers in participant failures (a message size, for example). It's harmless.CHANGELOG.md:172leaves out that the firstcause'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
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
rejectedandresponse, 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.tsnow holdsdescribeSendError,toSendFailureand the scrub helpers, moved unchanged fromsrc/auth/magic-link-send.ts, which imports them from there. Only the doc comment ontoSendFailurechanged, to say who uses it now.src/email/send.ts: the three senders go through one localsend(message). It turns a rejection intotoSendFailure(reason), so it keeps the message (addresses blanked),code,responseCode, and the cause's message and code. It still rejects, so pg-boss still retriesreminderSendandslotChangeSend. The log calls themselves don't change.Tests
src/email/send.test.tscovers each of the three senders, with a nodemailer-style refusal and with a realResendTransportagainst a stubbed 422 body. Each one rejects with nopat@example.comin 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.tsrunsnotifyCommitmentCreatedwith a refusing transport and the production logger options. The "confirmation email failed" line keepsEENVELOPEand has no address. It fails onmain'ssend.ts.pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test(3894 passed) andpnpm test:db(914 passed).Generated by Claude Code