Skip to content

Handle closed stdout, report align's dropped input, and tidy CLI edge cases - #4

Merged
honbin merged 6 commits into
mainfrom
fix/broken-pipe-and-align-skipped
Oct 19, 2026
Merged

honbin merged 6 commits into
mainfrom
fix/broken-pipe-and-align-skipped

Conversation

@honbin

@honbin honbin commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Handle a closed stdout quietly. ts-series and ts-align panicked (exit 101) and ts-burst exited 1 with Error: Os { code: 32, kind: BrokenPipe, .. } when piped into | head. ts-dist had the same latent issue via println!. All four now write through a BufWriter and treat BrokenPipe as a clean stop (exit 0), matching ts-window / ts-window-audit / ts-timeline.
  • Report what ts-align drops from its input. Unparseable lines were skipped silently, and duplicate timestamps collapsed to the last value, so the per-file counts in the stderr summary hid both. Each is now reported per file on stderr (skipped N unparseable line(s), N duplicate timestamp(s), last value kept). Join behavior and stdout are unchanged.
  • Make ts-burst return ExitCode like the other tools. Read/write errors now print a ts-burst: … message instead of Rust's Debug-formatted Error.
  • Print -0 as 0 in ts-series values and ts-timeline min/max labels. fmt_minmax now compares min/max numerically, so a -0/0 pair no longer falls back to the raw min -0 · max 0. Tooltips in ts-timeline still show the raw value.
  • Reject single-value flags given more than once (previously the last one silently won): --from / --to / --field (ts-window), --from / --to / --limit (ts-window-audit), --window (ts-correlate), --display-offset (ts-timeline). --series stays repeatable.
  • README: say which tools read files instead of stdin (ts-correlate, ts-align, ts-timeline), match ts-align's stderr summary wording, and mention its skipped/duplicate reporting.

Verification

  • cargo fmt --check — passed
  • cargo clippy --workspace --all-targets -- -D warnings — passed
  • cargo test --workspace — passed
  • New tests:
    • closed_stdout_exits_quietly for burst / series / dist / align. stdout is a pipe whose read end is dropped before spawn, so every write deterministically hits a closed pipe.
    • reports_skipped_lines_and_duplicates for align (fixture dup.txt).
    • negative_zero_prints_as_zero (series CLI), plus -0 cases for fmt_val / fmt_minmax in timeline's unit tests.
    • rejects_repeated_* for window / window-audit / correlate / timeline.
  • The broken-pipe, align-reporting and fmt_minmax tests fail without their fixes and pass with them.
  • Manually confirmed: a 200k-line input piped into | head -1 exits 0 for series / align / burst, and ts-timeline labels a -0/0 series as min 0 · max 0.

🤖 Generated with Claude Code

ts-series and ts-align panicked (exit 101) and ts-burst exited 1 with a
raw `Error: Os { .. BrokenPipe .. }` when piped into `head`; ts-dist had
the same latent issue. They now write through a BufWriter and treat
BrokenPipe as a clean stop, matching ts-window / ts-window-audit /
ts-timeline.

ts-align silently ignored unparseable lines and collapsed duplicate
timestamps, so its per-file counts hid both. It now reports each per file
on stderr, like the other tools' `skipped N` line.
main mixed io::Result with std::process::exit; read and write errors now
print a ts-burst: message instead of Rust's Debug-formatted Error.
fmt_val's integer branch rendered -0.0 as "-0" (e.g. a CloudWatch value
of -0). Tooltips in timeline still show the raw value.
--from/--to/--field (window), --from/--to/--limit (window-audit),
--window (correlate) and --display-offset (timeline) silently kept the
last value, so a mistyped repeat changed the query without notice.
--series stays repeatable.
The fallback compared Display strings, so -0 and 0 counted as distinct
and the label read "min -0 · max 0" despite fmt_val normalizing -0.
@honbin
honbin merged commit 12e82dd into main Oct 19, 2026
1 check passed
@honbin
honbin deleted the fix/broken-pipe-and-align-skipped branch October 19, 2026 23:44
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.

1 participant