An invalid --keep-newer-than is checked only after the backup, which is then reported as failed and retention never runs #307

Closed
opened 2026-10-13 00:47:12 +02:00 by clawbot · 1 comment
Collaborator

Found by the defect hunt in #288 (parts 1 and 5).

What is wrong: snapshot create (internal/cli/snapshot.go) does not check --keep-newer-than; it is first parsed by the post-backup prune (runPostBackupPrune in internal/vaultik/snapshot.go). With a value the parser rejects, the backup completes and uploads its snapshot, then the command prints "Snapshot creation failed: post-backup prune: purging old snapshots: invalid duration ..." and exits 1. Retention never runs, so such a cron line adds a snapshot every night, reports each as failed, and never deletes any. Without --prune, --keep-newer-than garbage is ignored and the run exits 0.

How it was shown: snapshot create ex --prune --keep-newer-than 1.5d (and 4x) exited 1 with that message, and snapshot list --json then showed the new snapshot with remote_present: true.

Definition of done

  • An invalid --keep-newer-than, and --keep-newer-than without --prune, are rejected before the backup starts: non-zero exit, nothing created.
  • A failure in the post-backup prune after a good backup is reported as a prune failure, not as a failed snapshot creation.
  • Tests cover both.

Model: opus-5-5

Found by the defect hunt in https://git.eeqj.de/sneak/vaultik/issues/288 (parts 1 and 5). **What is wrong:** `snapshot create` (`internal/cli/snapshot.go`) does not check `--keep-newer-than`; it is first parsed by the post-backup prune (`runPostBackupPrune` in `internal/vaultik/snapshot.go`). With a value the parser rejects, the backup completes and uploads its snapshot, then the command prints "Snapshot creation failed: post-backup prune: purging old snapshots: invalid duration ..." and exits 1. Retention never runs, so such a cron line adds a snapshot every night, reports each as failed, and never deletes any. Without `--prune`, `--keep-newer-than garbage` is ignored and the run exits 0. **How it was shown:** `snapshot create ex --prune --keep-newer-than 1.5d` (and `4x`) exited 1 with that message, and `snapshot list --json` then showed the new snapshot with `remote_present: true`. **Definition of done** - An invalid `--keep-newer-than`, and `--keep-newer-than` without `--prune`, are rejected before the backup starts: non-zero exit, nothing created. - A failure in the post-backup prune after a good backup is reported as a prune failure, not as a failed snapshot creation. - Tests cover both. Model: opus-5-5
clawbot self-assigned this 2026-10-13 00:47:12 +02:00
Author
Collaborator

Fixed in #346: snapshot create now rejects an invalid --keep-newer-than, or one given without --prune, before it starts, and a failed post-backup prune is reported as the prune's failure rather than as a failed snapshot creation.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/vaultik/pulls/346: `snapshot create` now rejects an invalid `--keep-newer-than`, or one given without `--prune`, before it starts, and a failed post-backup prune is reported as the prune's failure rather than as a failed snapshot creation. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/vaultik#307