Repository navigation
test: every --json command prints exactly one JSON document on stdout - #54
Merged
Merged
Conversation
Walks the command tree, requires a case for every command with a --json flag, runs each against httptest fakes with os.Stdout/os.Stderr redirected to files, and asserts stdout is exactly one JSON document (JSON Lines for the commands that follow a run) with no hint text. The one-time trigger note is asserted on stderr. No behaviour change: the prod E2E report came from a 2>&1 redirect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…--json guard Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 14, 2026
sre-helmcode
pushed a commit
that referenced
this pull request
Oct 20, 2026
Brings #50, #51, #52, #53, #54, #56 and #57 onto the new structure: - mimo-v2.6-flash, qwen3.8-flash at 1M, and the Codex model catalogue: the writer changes go to internal/tools, the catalogue and its embedded prompt to internal/tools/codexprompt. - BYOK runs, secrets and automation writes, and notifications: the commands go to internal/cli and hang off NewRootCmd; their goldens to internal/cli/testdata. - The --json contract test counts the commands with a --json of their own, not the one every command inherits from the root. - The embedded Codex prompt is Apache-2.0: its NOTICE and licence are now in THIRD-PARTY-NOTICES.txt. - Messages without em dashes, and the new code lint-clean.
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.
What
A guard test for the
--jsoncontract: with--json, stdout carries exactly one JSON document (JSON Lines for the commands that follow a run:nan run,nan automations run,nan runs logs) and nothing else; every hint, note and warning goes to stderr.cmd/json_output_test.go:TestEveryJSONCommandIsCoveredwalks the cobra tree and fails if a command with a--jsonflag has no case (and if a case names a command without one), so a new--jsoncommand cannot ship unchecked.TestJSONStdoutIsOnlyJSONruns all 24--jsoncommands (30 invocations, including--detach,-f, rotate with--url --secret --no-grace, secrets set create and replace) through the real command tree against httptest fakes, withos.Stdout/os.Stderrredirected to files as a shell redirect sees them. It asserts one JSON document (or valid JSON Lines), no hint text, no control characters, no secret value, and the documented exit code.TestTriggersAddJSONKeepsTheNoteOnStderrpins the case from the report: URL and signing secret in the JSON, the one-time note on stderr.Why
The 0.1.33 prod E2E reported
nan automations triggers add ... --json | jqfailing on the "Store these now" note. The investigation found no CLI bug: the note already goes to stderr; the E2E ran> out.json 2>&1. An audit of every--jsoncommand found no stdout leak. This PR locks the contract in.Evidence
approval_kindswarning to stdout inautomations create --json, both fail the test.go build ./...,go vet ./...,gofmt -l .clean;go test ./...green.Deploy notes
Test only, no behaviour change:
internal/tui.Versionis NOT bumped, so merging publishes no release.🤖 Generated with Claude Code