fix: round-trip non-UTF-8 text files instead of crashing with UnicodeDecodeError - #146
Open
vitali87 wants to merge 1 commit into
Open
fix: round-trip non-UTF-8 text files instead of crashing with UnicodeDecodeError#146vitali87 wants to merge 1 commit into
vitali87 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
vitali87
force-pushed
the
fix/non-utf8-file-content
branch
from
August 30, 2026 19:15
3ff09d9 to
6c0651d
Compare
vitali87
force-pushed
the
fix/non-utf8-file-content
branch
from
August 30, 2026 19:16
6c0651d to
bbb7bdd
Compare
vitali87
force-pushed
the
fix/non-utf8-file-content
branch
from
August 30, 2026 19:17
bbb7bdd to
088ee7a
Compare
vitali87
force-pushed
the
fix/non-utf8-file-content
branch
from
August 31, 2026 01:10
088ee7a to
494f537
Compare
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.
Summary
Git diffs any NUL-free file as text, so a latin-1
.txt/.properties/ legacy source reachedextract_diffand_get_base_file_content, whose strict.decode("utf-8")raised an uncaughtUnicodeDecodeError— a raw traceback frompr-split split.The fix keeps such files' bytes intact end to end:
extract_diff/_get_base_file_contentdecode witherrors="surrogateescape", and the worker writes files back with the same handler, so the materialised sub-PR file is byte-identical to the dev blob_utf8_safeat the single choke point (_count_tokens/_call_llm), replacing undecodable bytes with U+FFFD so the JSON request bodies stay validsave_planwritesjson.dumps(..., ensure_ascii=True)(which escapes lone surrogates as\udcXX) andload_planreads viajson.loads, so--dry-run→executeround-tripsraw_difflosslesslyStacked on #113 (top of stack #81, where the bytes-based capture from #70 lives).
Test plan
_call_llm/_count_tokensreceive replaced text; plan save/load round-trips a surrogate-bearingraw_diff— all four fail on the base