fix(sandbox): preserve trailing whitespace in filenames from list_dir and glob in remote providers - #4980
Open
shoemoney wants to merge 1 commit into
Open
Conversation
…mote providers The list_dir and glob parsers in the e2b, OpenSandbox, AIO, Tenki, and BoxLite providers called .strip() on every line of find output. A filename that legitimately ends (or begins) in whitespace was corrupted, so the listed path never resolved on any follow-up file API call, and the remote providers diverged from LocalSandbox, which preserves such names via pathlib. splitlines() already removes the line terminators, so filter empty lines only and keep each entry verbatim. Same class of bug as the e2b _sync_outputs_to_host fix (bytedance#4861), applied to the search parsers. Adds a trailing-space regression test per provider at the seam each suite already uses.
|
|
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.
Why
The remote sandbox providers parse
findoutput forlist_dirandglobby calling.strip()on every line. A filename that legitimately ends (or begins) in whitespace, such as"notes.txt ", comes back corrupted: the listed path does not exist, so every follow-upread_file/grep/globon it misses the real file.LocalSandboxuses pathlib and preserves such names, so behavior silently diverges between local and remote providers.#4861 fixed this exact class in the e2b
_sync_outputs_to_hostpath, with the rationale that the delimiter already provides an unambiguous boundary, so stripping is harmful ("NUL already delimits records, so do NOT strip"). The same reasoning applies to the newline-delimitedfindoutput here:splitlines()has already removed the terminator, and anything else on the line is part of the filename. This PR applies that fix to the remaining parsers, nine strip sites across the five providers.What changed
list_dirandglobin the five remote providers (e2b, OpenSandbox, AIO Sandbox, Tenki, BoxLite) now return filenames verbatim, matchingLocalSandbox. Empty-line filtering is kept; only the per-entry strip is removed. No API or signature changes.Surface area
docker/or sandboxed executionBug fix verification
backend/tests/test_e2b_sandbox_provider.py::test_list_dir_preserves_trailing_space_in_filenameand::test_glob_preserves_trailing_space_in_filename,backend/tests/test_opensandbox_provider.py::test_list_dir_and_glob_preserve_trailing_space_in_filename,backend/tests/test_aio_sandbox.py::test_list_dir_preserves_trailing_space_in_filename,backend/tests/test_tenki_provider.py::test_search_preserves_trailing_space_in_filename,backend/tests/test_boxlite_provider.py::test_list_dir_and_glob_preserve_trailing_space_in_filenamemainand green on this branch? yes, all six fail onmain('.../notes.txt' != '.../notes.txt ') and pass with the fixValidation
cd backend && uv run pytest -m "not live"on the five touched test files: 349 passed, 1 skipped (baseline 343 passed). Adjacent suites (test_sandbox_search_tools.py,test_remote_sandbox_backend.py, aio provider/local-backend): 138 passed.ruff checkandruff format --checkclean on all touched files.AI assistance
Tool(s) used: Claude (pair programming)
How you used it: Written in conjunction with my pair programmer Claude.