Skip to content

fix(read): fallback to raw bytes for non-UTF-8 reads#1019

Open
em0t wants to merge 1 commit intortk-ai:developfrom
em0t:fix/read-binary-fallback
Open

fix(read): fallback to raw bytes for non-UTF-8 reads#1019
em0t wants to merge 1 commit intortk-ai:developfrom
em0t:fix/read-binary-fallback

Conversation

@em0t
Copy link
Copy Markdown
Contributor

@em0t em0t commented Apr 4, 2026

Summary

  • preserve plain raw-read semantics for non-UTF-8 files by falling back to raw byte passthrough instead of failing early in rtk read
  • keep the fallback narrow: it only applies to unfiltered reads with no line windows and no line numbers
  • leave text-oriented modes unchanged, so filtered reads and -n still require valid UTF-8
  • add regression coverage for the binary fallback gate

Minimal Cases

non-UTF-8 raw read

Raw

/bin/cat nonutf8.bin >/dev/null
exit 0

Previous RTK

rtk read nonutf8.bin >/dev/null
stderr contains: stream did not contain valid UTF-8
exit 1

This PR

rtk read nonutf8.bin >/dev/null
exit 0

Testing

  • cargo fmt --all
  • cargo test test_supports_binary_passthrough -- --nocapture
  • cargo test --all
  • cargo clippy --all-targets (existing repo warnings only; none introduced by this PR)

Signed-off-by: em0t <10153971+em0t@users.noreply.github.com>
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