1 Commits
Author SHA1 Message Date
sneak b72b6ded58 Write only the document to stdout from snapshot remove --json (closes #251)
check / check (push) Successful in 18m5s
When the destination store cannot be reached, `snapshot remove` still
removes the snapshot from the local index and warns. The warning went
through the UI, which writes to stdout, so under `--json` it landed
ahead of the document and `| jq` failed on a command that exited 0.
Under `--json` the UI warning is now skipped; the logger's warning
already goes to stderr.

The new test runs the command through `Entry` against a missing
destination directory and decodes stdout as exactly one JSON document.

Judgement call: under `--json` the stderr warning is the log record,
which names the error but not the `vaultik prune` follow-up.

Model: opus-5-5
2026-10-06 23:24:14 +00:00
3 changed files with 4 additions and 8 deletions
+1 -2
View File
@@ -28,8 +28,7 @@ the tag exists and is exercised; what is left is merging `next` to
warning that the snapshot's metadata was left on the destination store
went to stdout ahead of the document, breaking `| jq` on a command that
exited 0. Under `--json` the warning now reaches stderr only, through
the logger, whose record now also says to run `vaultik prune` once the
destination store is reachable.
the logger.
- 2026-10-06: Made command output follow the README's stdout and stderr
rules ([issue #224](https://git.eeqj.de/sneak/vaultik/issues/224)). The
+1 -3
View File
@@ -91,8 +91,7 @@ func TestEntryJSONFailureIsReportedOnStderr(t *testing.T) {
// --json` against a destination directory that does not exist. The
// command still exits 0 after removing the snapshot from the local
// index. Its stdout must hold the document alone, with the warning
// about the destination store, and the `vaultik prune` follow-up, on
// stderr.
// about the destination store on stderr.
//
//nolint:paralleltest // replaces os.Args, os.Stdout, os.Stderr and the xdg globals
func TestEntrySnapshotRemoveJSONWarningIsOnStderr(t *testing.T) {
@@ -105,7 +104,6 @@ func TestEntrySnapshotRemoveJSONWarningIsOnStderr(t *testing.T) {
requireExactlyOneJSONDocument(t, stdout)
assert.Contains(t, stderr,
"Could not remove snapshot metadata from remote storage")
assert.Contains(t, stderr, "run 'vaultik prune'")
}
// writeMissingDestinationConfig builds a config whose destination
+2 -3
View File
@@ -1260,9 +1260,8 @@ func (v *Vaultik) removeSnapshotRemote(snapshotID string, opts *RemoveOptions) b
err := v.deleteRemoteSnapshotByKey(remoteKey)
if err != nil {
log.Warn("Could not remove snapshot metadata from remote storage; "+
"run '"+pruneCommandHint+"' once the remote is reachable "+
"to finish cleanup", "error", err)
log.Warn("Could not remove snapshot metadata from remote storage",
"error", err)
// The UI writes to stdout, which under --json holds only the
// document; the log record above is the warning on stderr.