Repository navigation
fix(cli): don't hang on ci explain with no --log in a terminal - #366
Merged
Merged
Conversation
When --log is omitted the log is read from stdin, which is right for the piped one-liner (`gh run view <id> --log-failed | patchrail ci explain`). But running `patchrail ci explain` interactively with nothing piped hit a blocking stdin.read() that waited forever with zero output -- a first-timer who forgot --log just saw a frozen screen. _read_log now detects an interactive terminal on stdin (isatty) and raises LogReadError with an actionable hint; explain/classify/pilot-pack/redact print it to stderr and exit 2, the same contract as the other bad-input cases. A real pipe or file redirect is untouched, so the documented one-liner keeps working.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
--logis omitted, PatchRail reads the log from stdin — correct for the documented one-liner:But a first-timer who just runs
patchrail ci explainin a terminal — forgetting--log, with nothing piped in — hit a blockingsys.stdin.read()that waited forever with zero output. The program looked frozen or crashed, with no hint that it wanted input. Reproduced against the published 0.7.2 wheel (hangs >6s, no output, on a pty stdin).Fix
_read_lognow detects an interactive terminal on stdin (isatty()) with no--logand raisesLogReadErrorwith an actionable hint instead of blocking.explain,classify,pilot-packandredactprint it to stderr and exit 2 — the same clean contract as the other bad-input cases (missing file, directory, unreadable file, empty input):A real pipe or file redirect is untouched (its stdin is not a TTY), so the documented one-liner and every scripted use keep working exactly as before.
Tests
explain/classify/redact): an interactive-TTY stdin with no--logexits 2, emits the hint, and leaks no traceback.isatty()→False).