fix(harness): replace inline Python edit with download-edit-upload in BaseSandboxFilesystem#2398
Open
chcodex wants to merge 1 commit into
Open
fix(harness): replace inline Python edit with download-edit-upload in BaseSandboxFilesystem#2398chcodex wants to merge 1 commit into
chcodex wants to merge 1 commit into
Conversation
… BaseSandboxFilesystem Bug: BaseSandboxFilesystem.edit() used an inline Python script via python3 -c with heredoc to perform string replacement. This approach had three issues: 1. \n in Java string is not a newline separator for python3 -c 2. jsonEscape() missed JSON control characters, causing parse errors 3. Hard dependency on python3 in sandbox images Fix: Restructure edit() to download file content via downloadFiles(), perform replacement using FilesystemUtils.performStringReplacement() (shared with LocalFilesystem and RemoteFilesystem), then upload the result via uploadFiles(). Also: - Add FilesystemUtils.ReplacementResult record for type-safe returns - Fix empty file guard semantics (null || length == 0) - Remove jsonEscape() and unused Base64 import - Use StandardCharsets.UTF_8 import instead of fully qualified name Tests: 47 tests passing across BaseSandboxFilesystemTest (22), FilesystemToolTest (5), LocalFilesystemModeTest (16), CompositeFilesystemTest (4). Covers unit (stubbed download/upload) and integration (real file I/O) scenarios including special characters, replaceAll, and error paths.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
Replace the fragile inline Python script in
BaseSandboxFilesystem.edit()with a download → Java replacement → upload approach, using the sameFilesystemUtils.performStringReplacement()shared byLocalFilesystemandRemoteFilesystem.Bugs Fixed
\nnot recognized bypython3 -c— Java's\\nwas passed literally, causingSyntaxErrorjsonEscape()incomplete — missing JSON control characters causedjson.loads()failurespython3dependency — now removedChanges
BaseSandboxFilesystem.javaedit(), removejsonEscape(),StandardCharsetsimportFilesystemUtils.javaReplacementResultrecord, change return type fromObject[]LocalFilesystem.javaReplacementResultRemoteFilesystem.javaReplacementResultBaseSandboxFilesystemTest.javaEditSpyFilesystemstub + 8 unit tests + 7 integration tests, realdownloadFiles/uploadFilesTests
47 tests passing across 4 test classes, 0 failures:
BaseSandboxFilesystemTest: 22 tests (13 unit + 9 integration)FilesystemToolTest: 5 testsLocalFilesystemModeTest: 16 testsCompositeFilesystemTest: 4 testsFixes #2397