Skip to content

cli: preserve BrokenPipe through JSON rendering #518

Description

@willwashburn

Problem

render_json maps serde_json::to_writer_pretty failures with io::Error::other, which converts a real BrokenPipe into ErrorKind::Other. Commands that silence EPIPE cannot recognize the failure.

A large JSON response piped to an early-exiting consumer demonstrates it:

set -o pipefail
burn search needle --limit 3000 --json | head -2

The pipeline is silent but exits 2; equivalent human output exits 0. Small payloads can fit the pipe buffer and hide the defect.

Expected behavior

render_json preserves the underlying I/O error kind so shared BrokenPipe handling exits quietly with status 0 for every JSON-producing command. serde_json::Error::io_error_kind() can be used to reconstruct the I/O error without a command-specific source-chain workaround.

Scope

Fix the shared helper in crates/relayburn-cli/src/render/json.rs and add a regression covering a payload large enough to force an early pipe close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions