You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk read <file> exits 1 with no output on a non-UTF-8 file, while --head-lines/--tail-lines on the same file are byte-exact #4065
A plain read of a file that isn't valid UTF-8 exits 1 and prints nothing:
$ printf'line one\nline two has a latin-1 byte: \xe9\nline three\n'> /tmp/nonutf8.log
$ rtk read /tmp/nonutf8.logcat: /tmp/nonutf8.log: invalid utf-8 sequence of 1 bytes from index 38
$ echo$?1
run() takes the byte path only when byte_line_window() returns Some, and that needs head_lines or tail_lines. A plain read has neither, falls through to String::from_utf8, and dies. The byte path is already byte-exact, it just isn't reachable without a window.
The hook decides which path a command lands on:
rewritten to
result
cat f → rtk read f
exit 1, no output
head -2 f → rtk read f --head-lines 2
works
tail -1 f → rtk read f --tail-lines 1
works
So cat on a log with one Latin-1 byte in it hands the agent an empty result, while head on the same file is fine. An empty result reads like an empty file.
CONTRIBUTING's Never Block rule covers this case: fall back to raw output instead of erroring out.
PR #1019 fixed it in April with a narrow gate (unfiltered, no window, no -n). A maintainer confirmed the bug on 2026-05-18 and asked for a rebase, the author rebased, and the branch then sat unreviewed until the stale bot closed it on 2026-09-14. I'll send a fresh PR against current develop.
rtk read on a non-UTF-8 file exits 1 with no output because the byte-exact path is only reached when --head-lines/--tail-lines is set; should fall back to raw byte output per Never Block rule.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/commands/read.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
The numbered path has the same failure: the hook rewrites cat -n f to rtk read -n f, and for a file with one Latin-1 byte (printf 'caf\xe9\nok\n') that returns exit 1, empty stdout and cat: latin1.txt: invalid utf-8 sequence of 1 bytes from index 3. Native cat -n prints 22 bytes. Checked on develop 41e6912. The earlier narrow gate excluded -n, so a fix here needs to cover it as well.
Activity
rtk-wshm-sync-bot commentedon Sep 14, 2026
🔍 Automated Triage
bugmediumSummary
rtk readon a non-UTF-8 file exits 1 with no output because the byte-exact path is only reached when--head-lines/--tail-linesis set; should fall back to raw byte output per Never Block rule.📁 Relevant files
src/commands/read.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
KuSh commentedon Oct 31, 2026
The numbered path has the same failure: the hook rewrites
cat -n ftortk read -n f, and for a file with one Latin-1 byte (printf 'caf\xe9\nok\n') that returns exit 1, empty stdout andcat: latin1.txt: invalid utf-8 sequence of 1 bytes from index 3. Nativecat -nprints 22 bytes. Checked on develop 41e6912. The earlier narrow gate excluded-n, so a fix here needs to cover it as well.sypsyp97 commentedon Nov 12, 2026
Fixed by #4066, released in 1.2.0.