Vaultik.UI doc comment misdescribes how --cron suppresses output #84

Closed
opened 2026-08-09 07:25:17 +02:00 by clawbot · 1 comment
Collaborator

Found while reworking PR #83. Small, but the wrong-comment class of bug is
worth closing out rather than leaving to mislead the next reader.

The Vaultik.UI field's doc comment states that the CLI swaps in a
discarding writer in --cron mode. That is not the mechanism. The actual
behavior is UI.SetQuiet(true), which silences informational output but
still permits Warning and Error.

The distinction matters. A discarding writer would mean nothing reaches
the user in cron mode; SetQuiet means warnings and errors still do.
Someone trusting the comment would reasonably assume diagnostics vanish
under --cron and could either suppress something that should surface, or
skip handling output that in fact still appears.

This is the same failure mode as the false comment corrected in #81
(snapshot.go:842 claimed the public manifest bytes carry no timestamp,
while the next statement wrote one) and it is adjacent to #82 (the logger
writes to stdout, so those still-permitted warnings can corrupt --json
output). A comment that misstates which output survives is exactly the
kind of thing that produces bugs like PR #83's finding 3.

Definition of done

  1. The Vaultik.UI doc comment names the real mechanism —
    UI.SetQuiet(true) — and states explicitly that Warning and Error are
    still emitted.
  2. Grep for any other comment or doc asserting that --cron discards or
    silences all output, and correct those too. Do not fix only the one
    instance.
  3. No behavior change — this is a comment fix. If the code turns out not
    to match the corrected description either, stop and report rather than
    changing behavior under a docs issue.
  4. script/cibuild exits 0.

Docs-only, so per repo policy this can skip adversarial review and merge
directly once the gate is green.

Found while reworking PR #83. Small, but the wrong-comment class of bug is worth closing out rather than leaving to mislead the next reader. The `Vaultik.UI` field's doc comment states that the CLI swaps in a discarding writer in `--cron` mode. That is not the mechanism. The actual behavior is `UI.SetQuiet(true)`, which silences informational output but **still permits Warning and Error**. The distinction matters. A discarding writer would mean nothing reaches the user in cron mode; `SetQuiet` means warnings and errors still do. Someone trusting the comment would reasonably assume diagnostics vanish under `--cron` and could either suppress something that should surface, or skip handling output that in fact still appears. This is the same failure mode as the false comment corrected in #81 (`snapshot.go:842` claimed the public manifest bytes carry no timestamp, while the next statement wrote one) and it is adjacent to #82 (the logger writes to stdout, so those still-permitted warnings can corrupt `--json` output). A comment that misstates which output survives is exactly the kind of thing that produces bugs like PR #83's finding 3. ## Definition of done 1. The `Vaultik.UI` doc comment names the real mechanism — `UI.SetQuiet(true)` — and states explicitly that Warning and Error are still emitted. 2. Grep for any other comment or doc asserting that `--cron` discards or silences all output, and correct those too. Do not fix only the one instance. 3. No behavior change — this is a comment fix. If the code turns out not to match the corrected description either, stop and report rather than changing behavior under a docs issue. 4. `script/cibuild` exits 0. Docs-only, so per repo policy this can skip adversarial review and merge directly once the gate is green.
clawbot added this to the 1.0.0 milestone 2026-08-09 07:25:17 +02:00
Author
Collaborator

Implementation plan (branch fix-ui-cron-comment off main):

I verified the claim against the code before writing anything:

  • internal/vaultik/vaultik.go:109 — the UI field is constructed as ui.New(os.Stdout).
  • internal/cli/app.go:58-60setupGlobals calls v.UI.SetQuiet(true) when opts.Cron || opts.Quiet. No writer is ever swapped; the field is never reassigned outside New.
  • internal/ui/ui.goquiet is checked by Beginf, Completef, Infof, Noticef, Detailf, Progressf, and Bannerf only. Warningf (line 158) and Errorf (line 167) have no quiet check and always write.

So the issue's description is correct and the existing comment is false. The only io.Discard UI writer in the tree is internal/snapshot/scanner.go:176, a fallback for a nil scanner UI — unrelated to --cron, which is likely where the "discarding writer" wording came from.

Planned changes (comments/docs only, no behavior change):

  1. Rewrite the Vaultik.UI doc comment to name UI.SetQuiet(true) in the cli layer, note it applies to --cron and --quiet alike, and state explicitly that Warning and Error are still emitted.
  2. README.md line 171 documents --cron as "Silent unless error", which understates what survives — warnings are emitted too. Correcting that line to name warnings as well.
  3. Audited the other --cron mentions and found them already accurate, so they stay untouched: internal/log/log.go:53-55, internal/cli/snapshot.go:104, internal/vaultik/snapshot.go:116-120.
  4. TODO.md entry in the same commit.

Out of scope and deliberately not touched: #82 (logger to stdout), the --json stderr workaround in snapshot_list.go, and the --cron cobra flag help string at internal/cli/snapshot.go:138 ("silent unless error") — that one carries the same imprecision as the README line, but it is program output rather than a comment, so changing it would violate the no-behavior-change constraint of this issue. Reporting it for separate triage.

Gate: script/cibuild, forced uncached.

Implementation plan (branch `fix-ui-cron-comment` off `main`): I verified the claim against the code before writing anything: - `internal/vaultik/vaultik.go:109` — the `UI` field is constructed as `ui.New(os.Stdout)`. - `internal/cli/app.go:58-60` — `setupGlobals` calls `v.UI.SetQuiet(true)` when `opts.Cron || opts.Quiet`. No writer is ever swapped; the field is never reassigned outside `New`. - `internal/ui/ui.go` — `quiet` is checked by `Beginf`, `Completef`, `Infof`, `Noticef`, `Detailf`, `Progressf`, and `Bannerf` only. `Warningf` (line 158) and `Errorf` (line 167) have no quiet check and always write. So the issue's description is correct and the existing comment is false. The only `io.Discard` UI writer in the tree is `internal/snapshot/scanner.go:176`, a fallback for a nil scanner UI — unrelated to `--cron`, which is likely where the "discarding writer" wording came from. Planned changes (comments/docs only, no behavior change): 1. Rewrite the `Vaultik.UI` doc comment to name `UI.SetQuiet(true)` in the cli layer, note it applies to `--cron` and `--quiet` alike, and state explicitly that Warning and Error are still emitted. 2. `README.md` line 171 documents `--cron` as "Silent unless error", which understates what survives — warnings are emitted too. Correcting that line to name warnings as well. 3. Audited the other `--cron` mentions and found them already accurate, so they stay untouched: `internal/log/log.go:53-55`, `internal/cli/snapshot.go:104`, `internal/vaultik/snapshot.go:116-120`. 4. `TODO.md` entry in the same commit. Out of scope and deliberately not touched: #82 (logger to stdout), the `--json` stderr workaround in `snapshot_list.go`, and the `--cron` cobra flag help string at `internal/cli/snapshot.go:138` ("silent unless error") — that one carries the same imprecision as the README line, but it is program output rather than a comment, so changing it would violate the no-behavior-change constraint of this issue. Reporting it for separate triage. Gate: `script/cibuild`, forced uncached.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/vaultik#84