Skip to content

fix(sandbox): a big file written on a local sandbox's host decodes on macOS too - #660

Merged
earakely-scale merged 1 commit into
mainfrom
edgararakelyan/macos-base64-stdin
Nov 13, 2026
Merged

earakely-scale merged 1 commit into
mainfrom
edgararakelyan/macos-base64-stdin

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

A file too big for one heredoc is written onto a sandbox's host in base64 chunks, then decoded with base64 -d <file>. macOS's base64 takes no file argument (base64: invalid argument …), so on a Mac every local sandbox write of more than 96 KiB of base64 failed.

Site routing hits this: it writes site_proxy.py onto a local computer's host. So a multi env that routes its sites to a local computer failed to deploy on macOS:

computer 'desktop' failed to route its sites: RuntimeError('Script failed (exit 64):
stderr: base64: invalid argument /tmp/_wft_…_etc_agentenv_sites_site_proxy.py.b64

How

The chunked write now decodes from stdin (base64 -d < <file>), which both GNU and BSD base64 accept. The small-file heredoc path already read stdin.

Testing

  • test_a_file_written_on_the_host_in_chunks_decodes_with_this_machines_own_base64 runs the write's own scripts with this machine's bash and base64, and checks the file decodes byte for byte.

    • On macOS it fails before the fix with the error above, and passes after.
    • On Linux (GNU base64) it passes both ways.
  • The two tests that pin the script text now expect the stdin form. tst/unit/providers/sandbox_providers: 1,705 passed on an amd64 and an arm64 Linux host.

  • Differential chaos run, the real write_host_file on main (1f5bef4) and on this branch, through four shells: the host's own bash (GNU coreutils 9.4), busybox 1.36, Alpine 3.20 and Ubuntu 24.04's dash. On an amd64 and an arm64 Linux host, no outcome differs between the two in any shell. It runs 25 checks:

    • sizes either side of the heredoc/chunk boundary, exact chunk multiples, every padding length, and 8 and 40 MB files;
    • all-zero, all-0xFF and every-byte content, and text full of quotes and $(...);
    • paths with spaces, quotes, unicode and an injection attempt (nothing ran);
    • overwriting a bigger file, a stale .b64 from an earlier run, and new nested folders;
    • a directory as the target, a read-only folder and a full 1 MB tmpfs, which fail the same way before and after;
    • 16 writes at once.

    On macOS's BSD base64, 20 of the cases fail on main, leaving an empty file and the .b64 behind, and all pass on this branch.

  • End to end on the same Linux hosts, on this branch:

    • computer/multi_env_computers_test.py, website_browser_test.py, browser_computer_test.py and ca_trust_test.py, which route sites to local computers;
    • task_step/test_run_code_named_sandbox_local.py;
    • agent/proxy_local_container_test.py and proxy_container_install_test.py;
    • providers/sandbox_providers/vm_sandbox_build_test.py.

    They pass: 52 on amd64. On arm64, four CDP-agent tests in browser_computer_test.py fail the same way on main: the echo agent's image build hits exec /bin/sh: exec format error. That's that host, not this change.

  • End to end on macOS (arm64, local Docker): a multi env whose website is routed to a local computer deploys on this branch, and failed at the site-routing step above without it.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues were found.

Summary

Changes chunked host-file writes to feed base64 -d through stdin so they work on macOS.

  • Large host writes feed the decoder through stdin.

Reviews (5) · Last reviewed commit: "fix(sandbox): a big file written on a lo..." · Reviewed by Greptile

… macOS too

The chunked write ran `base64 -d <file>`, which macOS's base64 refuses (it takes no file argument), so on a Mac every
local computer whose site routing writes site_proxy.py (over 96 KiB of base64) failed to deploy. Decode from stdin,
which GNU and BSD base64 both take; a test runs the write's own scripts with this machine's base64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 13, 2026 06:06
@earakely-scale
earakely-scale merged commit eac7660 into main Nov 13, 2026
61 of 63 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/macos-base64-stdin branch November 13, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant