Skip to content

fix(backup): make fatal errors JSON-safe#29

Open
tymrtn wants to merge 1 commit into
mainfrom
fix/issue-21-json-safe-fatal-errors-v2
Open

fix(backup): make fatal errors JSON-safe#29
tymrtn wants to merge 1 commit into
mainfrom
fix/issue-21-json-safe-fatal-errors-v2

Conversation

@tymrtn
Copy link
Copy Markdown
Owner

@tymrtn tymrtn commented May 5, 2026

Summary

Fixes #21

User-facing surface

  • No new public command names.
  • The public CLI remains envelope.
  • Affected commands are the existing envelope backup export, envelope backup verify, and envelope backup restore JSON paths.

Internal verification

These are Cargo package/test selectors, not user-facing commands:

  • CARGO_TARGET_DIR=/tmp/envelope-issue-21-target cargo fmt --check
  • CARGO_TARGET_DIR=/tmp/envelope-issue-21-target cargo test -p envelope-email-transport backup -- --nocapture
  • CARGO_TARGET_DIR=/tmp/envelope-issue-21-target cargo test -p envelope-email backup -- --nocapture

envelope-email-transport is the internal Rust crate containing email/backup/IMAP logic. The only installed command is still envelope.

Safety

  • No live mailbox export, restore, or migration was run.
  • No credentials inspected.

Backup export/verify/restore fatal errors now emit a structured
`fatal_error` JSON event (with `ok`, `phase`, `error` fields) before
exiting, so agents consuming `--json` output never see unstructured
plain-text on stderr for these commands.

- Add `FatalError` variant to `BackupEvent` enum
- Wrap error return path in `backup::run()` to emit JSON event
- Suppress duplicate plain-text stderr in main when --json is active
- Tests cover corrupt archive, missing manifest, unsafe restore target,
  and strict-mode verify failures in JSON mode

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make backup and restore fatal errors JSON-safe

1 participant