Repository navigation
fix(tools): surface unreadable patch targets as tool errors - #6372
Merged
VascoSch92 merged 1 commit intoNov 2, 2026
Merged
Conversation
Closed
75 of 86 tasks
VascoSch92
enabled auto-merge (squash)
November 2, 2026 13:57
VascoSch92
approved these changes
Nov 2, 2026
1 task done
1 of 9 tasks
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.
HUMAN:
Fixed the unreadable-file crash from #6348. I reviewed the diff and the tests; a patch must return a tool error when its target cannot be read as text.
AGENT:
Why
load_fileswrapped onlyFileNotFoundErrorin aDiffError. Any other read failure escaped the executor as an exception: a non-UTF-8 file raisedUnicodeDecodeError, and a directory raisedIsADirectoryErroron Linux/macOS (PermissionErroron Windows). The agent got a crash instead of an error observation, and on the non-UTF-8 path the file was left untouched but the failure was indistinguishable from a tool bug.Summary
OSErrorandUnicodeDecodeErrorfrom the patch's file read into aDiffError, so the executor returns an error observation like it does for every other invalid patch. The message names the path and the underlying error.test_update_non_utf8_file_returns_error_observationandtest_update_directory_returns_error_observationfrom theworktree-test-edge-casesbranch (commit f2fcf6e) without theirxfail(strict=True)markers, per the [Bug]: Edge-case tests expose ~70 bugs across the SDK, agent server, tools and workspaces #6348 menu's acceptance criteria.Issue Number
Part of #6348 (menu sub-items: "non-UTF-8 file raises UnicodeDecodeError out of the executor" and "updating a directory raises IsADirectoryError out of the executor")
How to Test
Before this change both cases raise out of
run_exec; after, both returnobs.is_errorand the non-UTF-8 file's bytes are unchanged. The fulltests/tools/apply_patch/suite is 15 passed.ruff check/formaton the touched files are clean.Type
Notes
Windows raises
PermissionErrorfor the directory case rather thanIsADirectoryError; both areOSError, so the single catch covers the platforms the tests run on.