Skip to content

fix: keep --json output parseable on stdout#286

Merged
socksy merged 2 commits into
developfrom
fix/json-output-purity
Jun 30, 2026
Merged

fix: keep --json output parseable on stdout#286
socksy merged 2 commits into
developfrom
fix/json-output-purity

Conversation

@socksy

@socksy socksy commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

--json is supposed to mean "stdout is JSON you can parse". Several commands broke that promise by mixing raw text into the output. tower run --detached --json printed a "See more" link after the success JSON. tower run --json against a missing app printed remediation steps after the error JSON. tower schedules list --json printed "No schedules found." instead of []. tower teams list --json printed the active-team legend after the data. And tower version --json wasn't JSON at all.

The root cause is the same everywhere: output::write() knows about MCP mode but not JSON mode. Instead of special-casing call sites, the broken sites now go through JSON-aware output functions. output.rs gains two: text() writes a human rendering or the data as JSON (the same shape as table() and list()), and note() writes presentation-only text that JSON mode suppresses. The run link travels inside the success message, with the scheduled run as structured data.

The new integration tests run each case with --json and parse stdout. Putting teams list under test required updating the mock server's /v1/session/refresh response, which had drifted from the generated client models. flake.lock gets a nixpkgs bump so binaryen comes from the binary cache on aarch64-darwin instead of compiling LLVM from source.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 684b13c6-35b8-4649-9d17-77eba9149288

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/json-output-purity

Comment @coderabbitai help to get the list of available commands and usage tips.

@socksy socksy force-pushed the fix/json-output-purity branch from 3794a87 to 64123af Compare June 2, 2026 12:24
@socksy socksy requested a review from konstantinoscs June 23, 2026 09:12
@socksy socksy requested a review from bradhe June 30, 2026 08:47
/// Writes a human-readable rendering of some data, or the data itself as JSON when
/// in JSON mode. Use this when a command's output is data that has both a plain text
/// and a JSON representation, mirroring `table` and `list`.
pub fn text<T: Serialize>(msg: &str, json_data: &T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok I made something similar in my PR and after this I can probably remove it

@konstantinoscs konstantinoscs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@socksy socksy merged commit 243a609 into develop Jun 30, 2026
30 checks passed
@socksy socksy deleted the fix/json-output-purity branch June 30, 2026 18:51
This was referenced Jul 1, 2026
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.

2 participants