fix(store): fail closed on encryption failure in save_email #236

Merged
KofTwentyTwo merged 1 commits from story/m6-cipher-fail-closed into dev 2026-07-30 03:00:52 +00:00
1 Commits
Author SHA1 Message Date
James Maes 71e3255544 fix(store): fail closed on encryption failure in save_email
encrypt_text_at_rest previously swallowed any AEAD failure with
unwrap_or_default(), silently persisting an empty ciphertext string
that is indistinguishable from a genuinely empty body on read-back.
Change its signature to return Result<String, CipherError> and
propagate failures through save_email as DatabaseError::Encryption,
resolved before the transaction begins so no row is ever written for
a message whose body failed to encrypt.

Refs #198, #162
2026-07-29 21:58:13 -05:00