Uh oh!
There was an error while loading. Please reload this page.
fix: keep --json output parseable on stdout - #286
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
3794a87 to
64123afCompare| /// 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) { |
There was a problem hiding this comment.
Ah ok I made something similar in my PR and after this I can probably remove it
Uh oh!
There was an error while loading. Please reload this page.
--jsonis supposed to mean "stdout is JSON you can parse". Several commands broke that promise by mixing raw text into the output.tower run --detached --jsonprinted a "See more" link after the success JSON.tower run --jsonagainst a missing app printed remediation steps after the error JSON.tower schedules list --jsonprinted "No schedules found." instead of[].tower teams list --jsonprinted the active-team legend after the data. Andtower version --jsonwasn'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 astable()andlist()), andnote()writes presentation-only text that JSON mode suppresses. The run link travels inside the success message, with the scheduled run as structureddata.The new integration tests run each case with
--jsonand parse stdout. Puttingteams listunder test required updating the mock server's/v1/session/refreshresponse, 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.