Skip to content

fix(sandbox): preserve trailing whitespace in filenames from list_dir and glob in remote providers - #4980

Open
shoemoney wants to merge 1 commit into
bytedance:mainfrom
shoemoney:fix/sandbox-listdir-glob-strip
Open

fix(sandbox): preserve trailing whitespace in filenames from list_dir and glob in remote providers#4980
shoemoney wants to merge 1 commit into
bytedance:mainfrom
shoemoney:fix/sandbox-listdir-glob-strip

Conversation

@shoemoney

Copy link
Copy Markdown

Why

The remote sandbox providers parse find output for list_dir and glob by 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-up read_file/grep/glob on it misses the real file. LocalSandbox uses 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_host path, 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-delimited find output 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_dir and glob in the five remote providers (e2b, OpenSandbox, AIO Sandbox, Tenki, BoxLite) now return filenames verbatim, matching LocalSandbox. Empty-line filtering is kept; only the per-entry strip is removed. No API or signature changes.

Surface area

  • Sandboxdocker/ or sandboxed execution

Bug fix verification

  • Test paths that reproduce the bug: backend/tests/test_e2b_sandbox_provider.py::test_list_dir_preserves_trailing_space_in_filename and ::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_filename
  • Did it go red on main and green on this branch? yes, all six fail on main ('.../notes.txt' != '.../notes.txt ') and pass with the fix

Validation

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 check and ruff format --check clean on all touched files.

AI assistance

Tool(s) used: Claude (pair programming)

How you used it: Written in conjunction with my pair programmer Claude.

  • I've read and understand every line of this change and take responsibility for it — it's not unreviewed AI output.

…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.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants