fix(stderr): route diagnostics to stderr, keep stdout for data#198
Merged
Conversation
`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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
vers run --jsonemits theWarning: vers.toml not found, using default configurationline on stdout, contaminating JSON output and breaking the canonicalvers run --json | jqpipeline: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.Println→fmt.Fprintln(os.Stderr, …)andfmt.Printf→fmt.Fprintf(os.Stderr, …)for the offending diagnostics:internal/runconfig/config.govers.toml not foundwarning (the headline bug)internal/presenters/run_presenter.go.vers directory not foundwarninginternal/presenters/branch_presenter.gono VM IDs returnederror +Failed to update HEADwarninginternal/handlers/upgrade.goskipping checksum verificationwarninginternal/handlers/kill.goabout to delete VMconfirmation header (precedes the interactive prompt)Verification
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.Printfcallsite ininternal/is worth doing as a follow-up.