Skip to content

Fix #518: preserve BrokenPipe through JSON rendering - #529

Open
willwashburn wants to merge 5 commits into
mainfrom
issue-518-json-broken-pipe
Open

Fix #518: preserve BrokenPipe through JSON rendering#529
willwashburn wants to merge 5 commits into
mainfrom
issue-518-json-broken-pipe

Conversation

@willwashburn

@willwashburn willwashburn commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Preserves the underlying io::ErrorKind when serde_json writers fail, allowing stdout JSON and JSONL renderers to recognize BrokenPipe and exit quietly when downstream consumers close early.

Scopes quiet EPIPE handling to stdout output. File and FIFO export failures remain reported and nonzero. This change is intentionally JSON-only; human-output broken-pipe handling remains separate.

Adds multi-megabyte early-closing consumer regressions for sessions list --json and stdout stamps export, including an assertion that all seeded session rows are retained.

Verification

  • cargo fmt --all -- --check
  • cargo test --workspace
  • Platform CI matrix

Fixes #518

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now treats stdout broken-pipe errors from JSON and JSONL output as quiet exits with code 0. File-output errors remain failures. Shared JSON conversion preserves BrokenPipe, and tests cover direct, wrapped, and end-to-end cases.

Changes

Quiet broken-pipe handling

Layer / File(s) Summary
JSON error preservation
Cargo.toml, crates/relayburn-cli/src/render/json.rs, crates/relayburn-cli/src/commands/update.rs
JSON rendering preserves I/O error kinds, marks stdout errors, converts serialization failures, and uses the shared conversion helper.
Quiet exit routing
crates/relayburn-cli/src/render/error.rs, crates/relayburn-cli/src/commands/stamps.rs
Stdout broken pipes return code 0 without generic reporting. Stamp export distinguishes stdout from file output and adds contextual errors.
Early-close validation
crates/relayburn-cli/tests/json_broken_pipe.rs, CHANGELOG.md
End-to-end tests cover early closure during JSON and JSONL output. The changelog documents quiet exits.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • burn#518: Preserves BrokenPipe in shared JSON rendering and adds regression coverage for early-closed output pipes.

Poem

A rabbit pipes JSON downstream,
Then closes the stream without a frown.
BrokenPipe keeps its name,
Quiet zero marks the game.
Files still report errors plain.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: preserving BrokenPipe errors through JSON rendering.
Description check ✅ Passed The description directly explains the JSON broken-pipe handling, scope, tests, and verification for this changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-518-json-broken-pipe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/relayburn-cli/src/render/error.rs
Comment thread crates/relayburn-cli/tests/json_broken_pipe.rs Outdated
Comment thread crates/relayburn-cli/src/commands/update.rs Outdated
@willwashburn

Copy link
Copy Markdown
Member Author

Addressed the Cubic review against a67039e:

  • Fixed the regression fixture: every seeded turn now has a unique fractional timestamp, and the test asserts all 4,096 rows were inserted. Independent reviewer verification measured the resulting sessions list --json payload at 3.3 MB.
  • Removed the inert stdout provenance mapping from update JSON output. Both callers intentionally discard print_json errors, so retaining that marker could not affect behavior; exact serde_json I/O-kind recovery remains.
  • Kept error-envelope behavior unchanged. The envelope is a best-effort rendering of an already-failed command; if its consumer closes early, the CLI must preserve the original command's failure exit code rather than convert it to success.

Verification: cargo fmt --check, git diff --check, targeted early-close regressions, and cargo test --workspace all pass. The paired adversarial reviewer independently delta-verified a67039e before push.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/relayburn-cli/tests/json_broken_pipe.rs (1)

46-89: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: extract shared spawn/read-prefix/assert logic.

Both tests spawn burn, read a fixed-size prefix, drop stdout, and assert output.status.success() with a similar failure message. Consider extracting a small helper that takes the CLI args and expected prefix bytes to reduce duplication.

Also applies to: 91-137

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/relayburn-cli/tests/json_broken_pipe.rs` around lines 46 - 89,
Optionally extract the duplicated child-process setup and early-stdout-close
assertion from the tests around
large_json_output_exits_zero_when_consumer_closes_early and the corresponding
test near lines 91–137 into a small helper. Have it accept the CLI arguments and
expected prefix bytes, then spawn burn, read and validate the prefix, drop
stdout, wait for completion, and assert successful exit while preserving the
existing diagnostic message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/relayburn-cli/tests/json_broken_pipe.rs`:
- Around line 46-89: Optionally extract the duplicated child-process setup and
early-stdout-close assertion from the tests around
large_json_output_exits_zero_when_consumer_closes_early and the corresponding
test near lines 91–137 into a small helper. Have it accept the CLI arguments and
expected prefix bytes, then spawn burn, read and validate the prefix, drop
stdout, wait for completion, and assert successful exit while preserving the
existing diagnostic message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aca9e9d5-6427-4b3d-88f6-d94e701f7b16

📥 Commits

Reviewing files that changed from the base of the PR and between 5b531d0 and a67039e.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • Cargo.toml
  • crates/relayburn-cli/src/commands/stamps.rs
  • crates/relayburn-cli/src/commands/update.rs
  • crates/relayburn-cli/src/render/error.rs
  • crates/relayburn-cli/src/render/json.rs
  • crates/relayburn-cli/tests/json_broken_pipe.rs

@willwashburn

Copy link
Copy Markdown
Member Author

Validated the final CodeRabbit feedback:

  • Restored the PR description with a declarative summary, JSON-only scope, verification, Fixes #518, and the required generator footer after Cubic had replaced it with a badge-only body.
  • Leaving the optional test-helper extraction as-is. The two regressions share a short process lifecycle, but their fixture construction and prefix assertions intentionally differ ([ for a JSON array versus { for JSONL), and factoring that small sequence would add indirection without improving defect coverage.

No code change is needed.

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.

cli: preserve BrokenPipe through JSON rendering

1 participant