Skip to content

feat(e2b): transfer files via envd Filesystem REST API #3339

Closed

Description

@chcodex

Problem

Single-file transfers go through shell+base64 over exec (33% inflation, per-argument length limits, 512KB truncation).

Additionally, filesystem calls must use the https://{port}-{sandboxId}.{domain} subdomain pattern (same as process calls): the https://sandbox.{domain} + header-routing form is rejected by self-hosted gateways with 400 {"error":"bad request"}.

Scope

Add E2bEnvdProcessClient.uploadFile (multipart POST) and downloadFile (GET) against /files, routed via envdHost(); keep E2b-Sandbox-Id/Port/X-Access-Token/Authorization headers. Plus unit tests.

Local branch: split/e2b-b-filesystem-rest (stacked on #3338's fix, split from #2196).

Activity

  1. oss-maintainer commented on Sep 28, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: enhancement | Status: Evaluated — mostly confirmed, one claim not reproducible from main (verified against main @ 525706267) | Feasibility: feasible | Severity: medium

    Claim Result Evidence
    Single-file transfers go through shell + base64 over exec Confirmed E2bSandbox extends AbstractBaseSandbox (E2bSandbox.java:42) and does not implement SandboxFileTransfer, so uploads fall back to building a one-file tar and calling hydrateWorkspace (SandboxBackedFilesystem.java:162-167, :261-280), and downloads run base64 <path> through exec (:197-213)
    512 KB truncation Confirmed, and it is the sharpest symptom exec output is capped at OUTPUT_TRUNCATE_BYTES = 512 * 1024 (E2bEnvdProcessClient.java:55, applied :93-105, :400-403); a truncated download is not detected as partial data — the trimmed base64 is decoded and the failure surfaces downstream (SandboxBackedFilesystem.java:201-207)
    ~33% base64 inflation Confirmed by construction Base64.getEncoder().encodeToString(all) on the whole archive (E2bSandbox.java:159-187)
    Per-argument length limits on upload Partially the E2B upload path already splits base64 into B64_CHUNK (4000-char) pieces written via python3 -c (E2bSandbox.java:159-187), so a single oversized argv entry is not what main does today; the cost is N sequential exec round trips instead
    Filesystem calls must use https://{port}-{sandboxId}.{domain} Not verifiable from main main never issues a filesystem call: envdHost() already returns the subdomain form for process calls (E2bEnvdProcessClient.java:384-391) and uploadFile/downloadFile//files do not exist yet. The self-hosted-gateway 400 bad request behaviour is an external observation we cannot reproduce from source

    Assessment. This is a well-scoped capability addition rather than a bug fix: implementing SandboxFileTransfer-style multipart upload/download against envd /files removes both the 512 KiB download ceiling and the multi-round-trip upload path, and it aligns E2B with KubernetesSandbox, which already has a native path. Keeping envdHost() as the single host builder for both process and filesystem calls is the right call, since the subdomain form is what main uses and validates today.

    Open points for the PR to settle (not blockers for the direction):

    1. Auth model for /files — X-Access-Token plus the Authorization: basicAuthUser(runUser) header are both sent on process calls today (:126-140); which does the Filesystem REST endpoint require on self-hosted envd?
    2. Relative vs absolute paths and the fallback rule when a path is not absolute.
    3. Streaming vs buffering — the upload path currently materializes the full archive in memory (archive.readAllBytes(), E2bSandbox.java:159-162); multipart still needs a bound.
    4. Failure semantics: HTTP status vs error body, and whether a 413/gateway rejection falls back to exec or fails fast.
    5. Test split: unit tests for URL/header construction plus an integration test gated on E2B credentials, matching the existing E2bEnvdProcessClientTest / E2bSandboxRecoveryTest layout.

    Coordination: #3338 (the envd stream-parsing fix) is the base of this stack and already has PR #3341 open; #3340 is stacked on this issue. Since you stated you will submit the PR, we are not generating one here — reply /approve if you would rather have an automated fix proposal from us.


    Automated evaluation by github-manager-bot

  2. added
    enhancement
    area/extensions
    on Sep 28, 2026
  3. oss-maintainer commented on Oct 1, 2026

    @oss-maintainer
    Collaborator

    Proposal window closed — no automated PR will be generated, and no competing PR will be filed from this proposal window

    The 72 h feedback window opened by the evaluation above (5871815695, posted 2026-09-28T14:18:24Z) reached its bound on 2026-10-01T14:18:24Z. Between the gate and that bound the thread received one non-maintainer comment (5878113443, @shleder, 2026-09-28T20:40:50Z) that carried none of the three feedback commands, so the window closes unanswered and automated PR generation for this issue is skipped.

    This is not a case of an unowned fix path. Community PR #3343 (feat(e2b): transfer files via envd Filesystem REST API [2/3], authored by @chcodex) cross-references this issue and implements exactly the seam the evaluation described — envd Filesystem REST transfer as the native path, stacked on the #3338/#3341 work. As of this read #3343 is open, not a draft, unmerged (merged_at: null), head 8fd39b3270c50007f6e6555bed61583e8f3ffe95, last updated 2026-09-28T16:36:32Z. Filing a second PR against the same seam is the duplicate-fix collision this window policy exists to prevent, which is why the proposal is stood down rather than escalated.

    The reporter also stated in the issue that they would submit the PR themselves, which is what the evaluation above deferred to; nothing here changes that.

    Nothing in this notice disputes the evaluation. The confirmed findings stand on main: single-file uploads fall back to tar + hydrateWorkspace and downloads to base64 through exec, E2bSandbox does not implement SandboxFileTransfer, and the OUTPUT_TRUNCATE_BYTES = 512 * 1024 ceiling on exec output makes an oversized download a silent truncation that only fails downstream. The open points recorded there — the auth model for /files, relative-vs-absolute path handling and the fallback rule, streaming versus buffering bounds, HTTP-status versus error-body failure semantics, and the unit/integration test split — remain the useful review checklist for #3343.

    The productive thread now is review of #3343: merge it, request changes, or close it. If #3343 is closed unmerged and this capability is still wanted, say so on this issue and the question will be re-evaluated against whatever main looks like at that point. No action is needed from anyone else, and this issue remains open as a feature request.

    Automated feedback-window maintenance by github-manager-bot

  4. xuchaoguo1983 commented on Oct 3, 2026

    @xuchaoguo1983

    Some measurements that may help prioritize this, from Alibaba Cloud Agent Sandbox (E2B protocol, cn-hangzhou, agentscope-extensions-sandbox-e2b 2.0.3):

    • With the current 4000-char base64 chunks over envd process calls, uploading a ~300 KB workspace projection (skills) takes about 9 s, and restoring a workspace of similar size from a snapshot is in the same range. Downloading (persisting the snapshot via tar to stdout) is fast by comparison.
    • As an experiment, writing a 1 MB file via exec with ~96 KB base64 chunks (just under Linux's 128 KB per-argument limit) took 1.1–2.5 s, i.e. roughly 5x faster than 4000-char chunks.

    So the transfer path dominates cold-start time whenever a sandbox is (re)created; a native file API as proposed here would remove most of it.

  5. added 2 commits that reference this issue on Oct 11, 2026
    65a35d4
    ec94460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/extensionsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions