snapshot remove --json prints its remote-cleanup warning on stdout, ahead of the document #251

Open
opened 2026-10-06 21:54:53 +02:00 by clawbot · 1 comment
Collaborator

Found while fixing #224 and filed separately: that issue covers commands that fail, and this one exits 0.

With a destination directory that does not exist, vaultik snapshot remove host_2026-01-01T00:00:00Z --json --force exits 0 and writes this to stdout:

⚠️  Warning: Could not remove snapshot metadata from remote: listing objects: checking destination directory: stat ...: no such file or directory. Run 'vaultik prune' once the remote is reachable to finish cleanup.
{
  "snapshot_id": "host_2026-01-01T00:00:00Z"
}

so | jq fails. removeSnapshotRemote in internal/vaultik/snapshot.go writes the warning through v.UI as well as the logger. v.UI writes to stdout, and --json quiets it, but warnings and errors always emit. The README says that under --json stdout holds the document and nothing else.

As far as traced, the other v.UI warnings either run only in table mode or belong to commands without --json.

Definition of done

  1. Under --json, snapshot remove against an unreachable destination writes only the document to stdout, and the warning still reaches stderr.
  2. A test runs it and decodes stdout as exactly one JSON document.
  3. make check passes.

Model: opus-5-5

Found while fixing https://git.eeqj.de/sneak/vaultik/issues/224 and filed separately: that issue covers commands that fail, and this one exits 0. With a destination directory that does not exist, `vaultik snapshot remove host_2026-01-01T00:00:00Z --json --force` exits 0 and writes this to stdout: ``` ⚠️ Warning: Could not remove snapshot metadata from remote: listing objects: checking destination directory: stat ...: no such file or directory. Run 'vaultik prune' once the remote is reachable to finish cleanup. { "snapshot_id": "host_2026-01-01T00:00:00Z" } ``` so `| jq` fails. `removeSnapshotRemote` in `internal/vaultik/snapshot.go` writes the warning through `v.UI` as well as the logger. `v.UI` writes to stdout, and `--json` quiets it, but warnings and errors always emit. The README says that under `--json` stdout holds the document and nothing else. As far as traced, the other `v.UI` warnings either run only in table mode or belong to commands without `--json`. ## Definition of done 1. Under `--json`, `snapshot remove` against an unreachable destination writes only the document to stdout, and the warning still reaches stderr. 2. A test runs it and decodes stdout as exactly one JSON document. 3. `make check` passes. Model: opus-5-5
clawbot self-assigned this 2026-10-06 21:59:26 +02:00
Author
Collaborator

Reproduced on next at 85d4ef1. Fixed in #256: under --json, snapshot remove no longer prints the stdout warning, and the logger's warning on stderr remains. That stderr record names the error but not the vaultik prune follow-up.

Model: opus-5-5

Reproduced on `next` at `85d4ef1`. Fixed in https://git.eeqj.de/sneak/vaultik/pulls/256: under `--json`, `snapshot remove` no longer prints the stdout warning, and the logger's warning on stderr remains. That stderr record names the error but not the `vaultik prune` follow-up. 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#251