Sieve redirect and vacation messages are lost when the blob write fails: original accepted with 250, no retry, no DSN

Tested and written with AI help.

Stalwart v1.1.0 (e7cde9b), official release binary, S3-compatible blob store (Backblaze B2 in production; local mock S3 for the repro).

What happens: when a user Sieve script runs redirect (or vacation) during local delivery, the generated message goes through queue_message (crates/smtp/src/outbound/local.rs:180-191). If the blob write fails, spool.rs:552-559 returns QueueOutcome::Failed without creating a queue entry, and the caller only checks for QuotaExceeded. The original is delivered and the sender gets 250, so the redirected copy (or vacation reply) is gone: no queue entry, no retry, no DSN. The same check is in crates/smtp/src/scripts/event_loop.rs:617.

In production this happens because an S3 PUT that times out is not retried (topic 2221): during an import we had 16 PUT timeouts in an hour across 3 nodes.

Repro: separate v1.1.0 instance, blob store S3 pointed at a local mock, timeout 5000 ms, maxRetries 3, verifyAfterWrite true. Account a@ has require ["copy"]; redirect :copy "[email protected]"; (and, separately, a vacation script). Fault = mock reads the PUT body, waits 8 s, closes the socket without replying, only for the redirect/vacation PUT.

Run Fault SMTP reply to sender S3 PUTs for the copy a@ (original) Copy Queue after 3 min
Control none 250 1, 200 delivered b@ received empty
Redirect 1 redirect PUT stalls 250 1, timed out delivered not received empty
Redirect 2 same 250 1, timed out, no further PUT delivered not received empty
Vacation control none 250 1, 200 delivered reply received empty
Vacation 1 reply PUT stalls 250 1, timed out delivered no reply empty

Log (redirect 1; addresses are test addresses):

2026-11-12T20:33:08Z INFO Sieve sending message (sieve.send-message) queueId = 340232688799581184, queueName = "local", total = 1, from = "[email protected]", to = ["[email protected]"], size = 1145
2026-11-12T20:33:13Z ERROR S3 error (store.s3-error) queueId = 340232688799581184, queueName = "local", from = "[email protected]", to = ["[email protected]"], size = 1145, total = 1, reason = "S3 request failed: ... operation timed out", causedBy = "crates/store/src/dispatch/blob.rs:175", details = "Failed to write blob.", causedBy = "crates/smtp/src/queue/spool.rs:556"
2026-11-12T20:33:13Z DEBUG DSN success notification (delivery.dsn-success) ... to = "[email protected]", code = 250
2026-11-12T20:33:13Z DEBUG Delivery completed (delivery.completed) ... to = ["[email protected]"], elapsed = 5000ms

The only trace is a generic store.s3-error carrying the original’s queueId and envelope; it never names the redirect target, and the preceding INFO sieve.send-message (emitted before queueing, crates/email/src/sieve/ingest.rs:316) reads as if the copy was sent.

Expected: a failed queue for a redirect/vacation either fails the local delivery temporarily (like a failed fileinto, crates/email/src/sieve/ingest.rs:824-854) so the sender retries, or is retried on its own, or at least emits a Sieve event naming the lost recipient.

Question: is ignoring Failed here deliberate? With :copy the local copy is already stored, so retrying the whole delivery would duplicate it; a separate retry for the generated message, or a 4xx when nothing was stored locally yet, would avoid the silent loss.

The code matches your description, but I couldn’t find anything in the docs or source that says whether ignoring Failed is deliberate.

In crates/smtp/src/outbound/local.rs:180-191, the result of message.queue(...) is compared only against QueueOutcome::QuotaExceeded. That case emits SieveEvent::QuotaExceeded. Any other outcome is dropped. In crates/smtp/src/queue/spool.rs:552-559, a failed blob write (or a failed encryption.pending.put) is logged with trc::error! and returns QueueOutcome::Failed before any queue entry is written. So nothing is queued or retried, and no event names the lost recipient. The only trace is the generic store.s3-error you quoted.

The code has no comment explaining the omission, so I can’t say whether it was intended. It looks like a gap in handling the Failed outcome. A fix would need to pick between the options you listed: a temporary failure of the local delivery, a separate retry for the generated message, or at least a Sieve event that names the recipient. The :copy duplication problem you noted is a real constraint on the first option.

Staff or a community member will need to confirm the intended behaviour and whether a fix is planned.

This isn’t covered in the current docs. A community member or staff member will follow up.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Ignoring Failed there wasn’t deliberate. Two changes fix this, and both ship in the next weekly Stalwart release.

The bigger one is in the S3 client. maxRetries only applied to retryable HTTP statuses and S3 error codes, and transport errors were retried only for reads, once. A PUT that timed out or lost its connection, like your stalled mock and the B2 timeouts, failed on the first attempt whatever maxRetries was set to. Every request now retries transport errors with backoff up to maxRetries. Blob keys are content hashes, so resending a PUT is safe. That covers every blob write, including incoming mail, which is also what was behind the timeouts in topic 2221.

If queueing a redirect, vacation reply or notification still fails after those retries, the server now logs sieve.unexpected-error with “Failed to queue Sieve generated message.” and the recipients that missed it, instead of dropping it silently.

We kept the delivery semantics as they are. A 4xx on the original only helps when nothing was stored yet, which you pointed out yourself, and even then a retry re-runs the whole script, while the vacation and duplicate ids from the first run are already recorded. So a failed generated message is logged and not retried on its own. With maxRetries at 3 and a 5 s timeout, a PUT against an endpoint that doesn’t answer now takes up to about 30 seconds before it gives up.

Thanks. Rechecked on v1.1.1 (3adead9), with v1.1.0 as the control on the same box. Same mock S3 as before: timeout 5000 ms, maxRetries 3, verifyAfterWrite on. Stall means the mock reads the body, waits 8 s, then closes.

Fault v1.1.0 v1.1.1
every PUT stalls 1 PUT, 500 at 5.0 s 4 PUTs, same key and body, 500 at 21.5 s
every PUT reset (RST) 1 PUT, 500 4 PUTs, 500 at 5.3 s
PUT stalls once 1 PUT, 500 2 PUTs, 200
every GET stalls 2 GETs, 500 4 GETs, 500 at 25.8 s
every PUT stalls, maxRetries 1 / 0 1 / 1 PUT 2 / 1 PUTs
redirect :copy, spool PUT stalls once copy lost 2 PUTs, b@ gets the copy
redirect :copy, spool PUT always stalls copy lost, only store.s3-error 4 PUTs, copy lost, sieve.unexpected-error “Failed to queue Sieve generated message.” from = a@, to = [b@]
vacation reply PUT stalls once reply lost 2 PUTs, reply delivered
vacation reply PUT always stalls reply lost 4 PUTs, reply lost, sieve.unexpected-error to = [b@]
no fault, 503 once (controls) ok ok

This matches what you described: retry with backoff up to maxRetries for every request (crates/s3/src/retry.rs:49, client.rs:350), and the Sieve event (smtp/src/outbound/local.rs:197). The original message got 250 every time.

One docs line is now out of date. docs/storage/backends/s3.md still says “A request that fails with a connection error is retried once”.

This also answers 2221. Notify was not tested.

Tested and written with AI help.

That table covers everything I wanted to see, including the 2221 case. The retry behaviour and the sieve.unexpected-error event match what shipped in v1.1.1, and the original getting 250 every time is expected.

The out-of-date line in the S3 docs is fixed now, along with the same claim in the FAQ entry on an unreachable S3 store. Both now say connection errors and timeouts are retried up to maxRetries times like the retryable statuses.