Skip to content

feat(sdks): support byte range reads via start/end in files.read#1364

Open
mishushakov wants to merge 1 commit into
mainfrom
mishushakov/range-header-file-reads
Open

feat(sdks): support byte range reads via start/end in files.read#1364
mishushakov wants to merge 1 commit into
mainfrom
mishushakov/range-header-file-reads

Conversation

@mishushakov
Copy link
Copy Markdown
Member

Summary

Adds optional start / end parameters to files.read in both the JS and Python SDKs (sync + async). When set, the SDKs send an HTTP Range: bytes=<start>-<end> header to GET /files — envd already serves this via http.ServeContent, so no infra change is needed. Semantics match HTTP Range (inclusive end, zero-based); negative values or inverted ranges throw InvalidArgumentError / InvalidArgumentException before any request is made. Closes #1054.

Test plan

  • pnpm run format, pnpm run lint, pnpm run typecheck
  • pnpm exec vitest run tests/sandbox/files/read.test.ts (needs live sandbox)
  • poetry run pytest tests/{sync,async}/sandbox_*/files/test_read.py (needs live sandbox)

🤖 Generated with Claude Code

Adds optional `start` / `end` parameters to `files.read` in both the JS
and Python SDKs. When set, the SDKs send an HTTP `Range: bytes=<start>-<end>`
header to `GET /files`, which envd already serves via `http.ServeContent`.
Semantics match HTTP Range (inclusive end, zero-based). Negative values and
inverted ranges raise `InvalidArgumentError` / `InvalidArgumentException`
before any request is made.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label May 28, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: 215f7cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
e2b Minor
@e2b/python-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor
Copy link
Copy Markdown

cursor Bot commented May 28, 2026

PR Summary

Low Risk
SDK-only API and header wiring on existing envd range support; validation is local before any request.

Overview
Adds optional start / end on files.read in the JS and Python SDKs (sync and async). When set, reads send Range: bytes=… on GET /files (inclusive, zero-based); invalid ranges fail locally with InvalidArgumentError / InvalidArgumentException. Docs note byte-range vs format: 'text' UTF-8 boundaries. Integration tests cover slices and rejection; a changeset marks a minor SDK release. No envd changes—range serving is already supported server-side.

Reviewed by Cursor Bugbot for commit 215f7cd. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

Package Artifacts

Built from 5711917. Download artifacts from this workflow run.

JS SDK (e2b@2.27.1-mishushakov-range-header-file-reads.0):

npm install ./e2b-2.27.1-mishushakov-range-header-file-reads.0.tgz

CLI (@e2b/cli@2.10.3-mishushakov-range-header-file-reads.0):

npm install ./e2b-cli-2.10.3-mishushakov-range-header-file-reads.0.tgz

Python SDK (e2b==2.25.0+mishushakov-range-header-file-reads):

pip install ./e2b-2.25.0+mishushakov.range.header.file.reads-py3-none-any.whl

@mishushakov mishushakov marked this pull request as ready for review May 28, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filesystem read with offset & length parameter

1 participant