Repository navigation
test(messaging): pin the retry verdict for the SMTP replies a project's server sends - #14544
Conversation
…project's SMTP sends 421 at the login and at RCPT, 451 at MAIL FROM and after DATA, 452 at RCPT and a host that never greets are worth repeating; 553 for the sender, 550 for the mailbox and 554 after DATA are final. Each is spoken by a real socket, as the existing cases are.
|
Review complete. No issues found — approved ✅. This PR extends
Reviewed commit: beb30e8 |
🟢 Tier S · Ready to mergeAdds SMTP refusal cases for additional temporary and permanent replies, including a timeout when the server never sends a greeting. The tests assert each failure’s retry verdict through the messaging SMTP adapter.
📂 Walkthrough · 1
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What
The only change is tests. The mails worker already classifies SMTP failures the way this work asked for (
7160cca211, "retry a project's SMTP that failed for now, end one that refused for good"):packages/messaging/src/Adapter/Email/SMTP.php,permanent()) marks a resultpermanentonly for a 5xx reply class (Utopia\SMTP\Outcome::fromCode), a missing required capability, or a login refused with a 5xx.Workers/Mails.phpthrowsPermanentFailurefor apermanentrefusal from a project's own SMTP. Any other failure throws a plainException, which is retriable.This PR covers the reply codes the existing data provider did not, each spoken by a real socket through
ScriptedSmtpServer:Already covered before this PR: 535 login, 554 greeting, 551 EHLO+HELO, 550 sender domain, 550 RCPT (permanent); 454 login, 421 greeting, 450 RCPT, 450 / 421 EHLO, hang-up, closed port (retriable); no STARTTLS when required (permanent); a multi-host list is permanent only when every host refused for good.
Seen red
I mutated
SMTP::permanent()and the per-recipientOutcome::Permanentchecks two ways and ranSMTPRefusalTest:With the source restored, all 28 cases pass (
bin/monorepo test messaging --linked: 142 unit tests OK), andbin/monorepo check messagingpasses Pint, PHPStan and Rector.Why production still dead-letters a 421
The 421 in sgp1 was thrown as
Exception(retriable), and it still went to the dead stream at attempt 1/1. Every production region runs the mails queue withmaxDeliver=1and no backoff (application-configurationcloud/production/cloud/*.yaml,_APP_CONNECTIONS_QUEUE_MAILS). A retriable failure cannot be retried until that changes. The proposed change isackWait=60&maxDeliver=3&backoff=60,300. It is tracked separately in appwrite-labs/cloud#6559 and not made here.Not covered
No unit test sits on the worker's
PermanentFailure/Exceptionmapping, because AGENTS.md keeps workers out of the unit suite. No E2E drives a project SMTP that answers 4xx through the mails worker and the NATS queue.Related: appwrite-labs/cloud#6448