Repository navigation
fix(mail): grade outbound delivery on the whole queue, not the top three reasons - #945
Merged
Hydralerne merged 2 commits intoSep 25, 2026
Conversation
…ree reasons parseMailQueue capped its reason list at MAX_DEFERRALS before returning, and checkMailDelivery graded that capped list. A relay refusal ranked below the three most common reasons never reached gradeDelivery, so a relayed box whose SASL credentials, TLS or egress to the smarthost were broken graded warn instead of fail. Return every distinct reason from the parse, grade that, and apply the cap in topDeferrals when building the response. The response still carries at most three rows.
The last-shown-row, other-host, empty-relay-host and direct-box rows grade the same with the cap in the parse, so they pin nothing about this change. Read the parse result without a non-null assertion, like the rest of the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkMailDeliverygraded outbound delivery on only the first three deferral reasons the queue reported, so a fatal reason ranked fourth or later was gradedwarninstead offail. It now grades on the whole queue and reports the top three reasons.Motivation
Refs #876. A queue with three benign deferrals ahead of an auth or TLS failure reported a healthy-looking
warn.Related issue
None required (bug fix). Refs #876.
Changes
apps/api/src/modules/mail/mail-delivery.service.ts:parseMailQueuekeeps every reason; newtopDeferralsreturns the first three for the report;checkMailDeliverygrades on all of them.apps/api/test/modules/mail/mail-delivery.service.test.ts: one existing test updated and fiveit.eachrows added, all failing onmain.Verification
Run twice in fresh worktrees (Bun 1.3.14, Vitest 4.0.18). Six production-file mutants were rebuilt and re-run; the test rows kill each of them. Verbatim output is in the sections below.
Checklist
bun run test,bun run --cwd <workspace> lint, andbun formatall pass locally (the touched test file, the API lint andbun formatwere run; the wholebun run testsuite was not)Summary
parseMailQueuecapped its deferral list atMAX_DEFERRALS(3) before returning it, andcheckMailDeliverygraded that capped list. A display cap was deciding the health verdict.failure naming it) is often the rarest line in the queue: one message has reached the relay
and been refused while older ones defer against ordinary receivers. Sorted by count and cut to
three, it never reached
gradeDelivery.warn("mail is moving late") instead offail.topDeferralswhen building the response. The response still carries at most three rows.e610b22f(production file +11/-2, the rest tests). Nonew dependencies, no reformatting of unrelated lines. The second commit is test-only (it drops
four table rows that passed without the fix); squash on merge is fine.
Both arms run at head
e610b22f. The test file holds 47 tests: 41 unchanged, 1 pre-existing testupdated (
caps the reasons it reports), 5 added as oneit.eachtable. All 6 new or updated testsfail on base; there are no controls.
Decisions
The change uses the project’s existing implementation path and adds a focused regression test; broader unrelated behavior remains out of scope.
Not run: no checks beyond the staged PR evidence were run during submission.
AI assistance: this bug was found and the fix and tests were drafted with AI tooling in my workflow; the tests and checks above were executed as pasted. I'm responsible for the change and will handle review feedback.