Skip to content

fix(stderr): route diagnostics to stderr, keep stdout for data#198

Merged
AlephNotation merged 1 commit into
mainfrom
fix/diagnostics-to-stderr
May 12, 2026
Merged

fix(stderr): route diagnostics to stderr, keep stdout for data#198
AlephNotation merged 1 commit into
mainfrom
fix/diagnostics-to-stderr

Conversation

@AlephNotation
Copy link
Copy Markdown
Contributor

Problem

vers run --json emits the Warning: vers.toml not found, using default configuration line on stdout, contaminating JSON output and breaking the canonical vers run --json | jq pipeline:

$ vers run --json 2>/dev/null
Warning: vers.toml not found, using default configuration   ← still here, on stdout
{
  "vm_id": "...",
  "head": "..."
}
$ vers run --json | jq .
jq: parse error: Invalid numeric literal at line 1, column 8

Same shape elsewhere — six diagnostics across runconfig, presenters, and handlers were using fmt.Println / fmt.Printf (stdout) instead of stderr.

Fix

Five files, swap fmt.Printlnfmt.Fprintln(os.Stderr, …) and fmt.Printffmt.Fprintf(os.Stderr, …) for the offending diagnostics:

File Diagnostic
internal/runconfig/config.go vers.toml not found warning (the headline bug)
internal/presenters/run_presenter.go .vers directory not found warning
internal/presenters/branch_presenter.go no VM IDs returned error + Failed to update HEAD warning
internal/handlers/upgrade.go skipping checksum verification warning
internal/handlers/kill.go about to delete VM confirmation header (precedes the interactive prompt)

Verification

$ vers run --json 2>/dev/null
{
  "vm_id": "a46c92a9-36b2-477a-a6f6-694b74945b09",
  "head": "a46c92a9-36b2-477a-a6f6-694b74945b09"
}

$ vers run --json 2>&1 >/dev/null
Warning: vers.toml not found, using default configuration

$ vers run --json | jq .vm_id
"a46c92a9-36b2-477a-a6f6-694b74945b09"

make build, gofmt, go test ./internal/... ./cmd/... all clean.

Addresses agent-native CLI principle 2 (data on stdout, diagnostics on stderr) from the audit. Not a comprehensive sweep — only fixes the cases I happened to see in this session. A broader pass over every fmt.Println / fmt.Printf callsite in internal/ is worth doing as a follow-up.

`vers run --json` previously emitted 'Warning: vers.toml not found...' to
stdout, contaminating the JSON output and breaking `vers run --json | jq`.
Same shape elsewhere \u2014 six diagnostics across runconfig, presenters, and
handlers were using `fmt.Println`/`Printf` (stdout) instead of stderr.

Fixed:
- internal/runconfig/config.go      'vers.toml not found' warning
- internal/presenters/run_presenter.go      '.vers directory not found' warning
- internal/presenters/branch_presenter.go   'no VM IDs returned' error + HEAD update warning
- internal/handlers/upgrade.go      'skipping checksum verification' warning
- internal/handlers/kill.go         'about to delete VM' confirmation header

After this, `vers run --json 2>/dev/null` produces clean JSON that
`jq` can parse. Addresses agent-native CLI principle 2 (data on stdout,
diagnostics on stderr).
@AlephNotation AlephNotation merged commit a5293c9 into main May 12, 2026
6 checks passed
@AlephNotation AlephNotation deleted the fix/diagnostics-to-stderr branch May 12, 2026 02:20
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.

1 participant