fix(sdk): expose download response metadata across all SDKs - #1597
Open
mengdehong wants to merge 5 commits into
Open
fix(sdk): expose download response metadata across all SDKs#1597mengdehong wants to merge 5 commits into
mengdehong wants to merge 5 commits into
Conversation
added 5 commits
August 22, 2026 11:23
mengdehong
requested review from
Pangjiping,
hittyt and
jwx0925
as code owners
August 22, 2026 04:48
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the OpenSandbox SDKs’ filesystem download APIs to optionally return HTTP response metadata (status code, Content-* headers, parsed Content-Range, etc.) alongside the downloaded body, enabling callers to reliably detect whether HTTP Range requests were honored (206) or ignored (200). It does so across Go, JavaScript, Python (async + sync), Kotlin, and C#, while preserving existing “body-only” methods by delegating them to the new detailed implementations.
Changes:
- Add new “detailed” download response models (e.g.,
ReadBytesResponse,ByteRange) and implement detailed download methods in each SDK, keeping existing download methods backward-compatible via delegation. - Implement consistent
Content-Rangeparsing behavior (including malformed values and unknown totals) and add stream wrappers that support explicit close/dispose for unconsumed/partially-consumed bodies. - Add/expand unit tests and update SDK docs to describe when to use detailed methods and how to close/dispose detailed stream bodies.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdks/sandbox/python/tests/test_filesystem_download_response.py | Adds Python async/sync tests for detailed download metadata + stream cleanup behavior. |
| sdks/sandbox/python/src/opensandbox/sync/services/filesystem.py | Extends sync filesystem service interface with detailed download method signatures. |
| sdks/sandbox/python/src/opensandbox/sync/adapters/isolated_filesystem_adapter.py | Implements sync detailed downloads and delegates legacy methods to detailed responses. |
| sdks/sandbox/python/src/opensandbox/sync/adapters/filesystem_adapter.py | Implements sync detailed downloads and stream bodies with explicit close support. |
| sdks/sandbox/python/src/opensandbox/services/filesystem.py | Extends async filesystem service interface with detailed download method signatures. |
| sdks/sandbox/python/src/opensandbox/models/filesystem.py | Introduces Python ByteRange, ReadBytesResponse, and closeable stream Protocols. |
| sdks/sandbox/python/src/opensandbox/models/init.py | Re-exports the new Python download response models/types from the package root. |
| sdks/sandbox/python/src/opensandbox/adapters/isolated_filesystem_adapter.py | Implements async detailed downloads and delegates legacy methods to detailed responses. |
| sdks/sandbox/python/src/opensandbox/adapters/filesystem_adapter.py | Implements async detailed downloads and stream bodies with explicit close support. |
| sdks/sandbox/python/src/opensandbox/adapters/download_response.py | Adds shared Python mapping/parsing utilities + stream wrappers that close httpx responses. |
| sdks/sandbox/kotlin/sandbox/src/test/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/FilesystemAdapterTest.kt | Adds Kotlin tests for detailed download metadata and legacy compatibility. |
| sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/IsolatedFilesystemAdapter.kt | Adds readByteArrayDetailed/readStreamDetailed and delegates legacy methods to detailed. |
| sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/FilesystemAdapter.kt | Adds readByteArrayDetailed/readStreamDetailed and delegates legacy methods to detailed. |
| sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/service/DownloadResponseMapper.kt | Adds Kotlin shared mapper parsing Content-Range + mapping response metadata. |
| sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/domain/services/Filesystem.kt | Extends Kotlin filesystem interface with detailed read methods. |
| sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/domain/models/execd/filesystem/FilesystemModels.kt | Introduces Kotlin ByteRange/ReadBytesResponse models and isPartial convenience property. |
| sdks/sandbox/javascript/tests/public-exports.test.mjs | Expands JS public export test to cover new stable download response types. |
| sdks/sandbox/javascript/tests/filesystem.download-response.test.mjs | Adds JS tests for detailed metadata mapping + stream cancel/cleanup behavior. |
| sdks/sandbox/javascript/src/services/filesystem.ts | Extends JS SandboxFiles interface with detailed download methods. |
| sdks/sandbox/javascript/src/models/filesystem.ts | Introduces JS ByteRange, ReadBytesResponse, and closeable ReadBytesStream types. |
| sdks/sandbox/javascript/src/index.ts | Exposes new JS filesystem models/types in the public entrypoint. |
| sdks/sandbox/javascript/src/adapters/isolatedFilesystemAdapter.ts | Implements readBytesDetailed/readBytesStreamDetailed and delegates legacy downloads. |
| sdks/sandbox/javascript/src/adapters/filesystemAdapter.ts | Implements readBytesDetailed/readBytesStreamDetailed and delegates legacy downloads. |
| sdks/sandbox/javascript/src/adapters/downloadResponse.ts | Adds JS response metadata mapper + closeable stream wrapper for Response bodies. |
| sdks/sandbox/go/sandbox_files.go | Adds Go Sandbox.DownloadFileResponse helper method. |
| sdks/sandbox/go/README.md | Documents the new Go download method that exposes response metadata. |
| sdks/sandbox/go/opensandbox_test.go | Adds Go tests for range ignored vs honored, Content-Range parsing, and body close behavior. |
| sdks/sandbox/go/execd.go | Introduces Go DownloadFileResponse/ByteRange, Content-Range parsing, and delegates legacy DownloadFile. |
| sdks/sandbox/csharp/tests/OpenSandbox.Tests/SandboxEgressLifecycleTests.cs | Updates C# test filesystem mock to implement newly-added detailed interface methods. |
| sdks/sandbox/csharp/tests/OpenSandbox.Tests/FilesystemAdapterTests.cs | Adds C# tests validating detailed metadata mapping and stream disposal behavior. |
| sdks/sandbox/csharp/src/OpenSandbox/Services/ISandboxFiles.cs | Extends C# filesystem interface with detailed download methods for bytes and streams. |
| sdks/sandbox/csharp/src/OpenSandbox/Models/Filesystem.cs | Introduces C# ByteRange, ReadBytesResponse<T>, and IAsyncReadBytesStream models. |
| sdks/sandbox/csharp/src/OpenSandbox/Internal/HttpClientWrapper.cs | Makes EnsureSuccessAsync internal to support adapter-level response handling. |
| sdks/sandbox/csharp/src/OpenSandbox/Adapters/FilesystemAdapter.cs | Implements detailed downloads, metadata mapping, and a disposable async stream wrapper. |
| docs/sdks/python.md | Documents Python detailed download APIs and explicit close guidance for streams. |
| docs/sdks/kotlin.md | Documents Kotlin detailed download APIs. |
| docs/sdks/javascript.md | Documents JS detailed download APIs and explicit close guidance for streams. |
| docs/sdks/go.md | Documents Go DownloadFileResponse for metadata-aware downloads. |
| docs/sdks/csharp.md | Documents C# detailed download APIs and explicit dispose guidance for streams. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
206 Partial Contentfrom a server or proxy ignoring the Range request and returning200 OK.Content-TypeandContent-Disposition;Content-Length;Content-Range;isPartialconvenience property.Content-Rangevalues such asbytes 0-1023/4096into start, end, and total fields. Unknown totals use-1; malformed values preserve the raw header while numeric fields use-1.New methods:
DownloadFileResponsereadBytesDetailed,readBytesStreamDetailedread_bytes_detailed,read_bytes_stream_detailed(async and sync)readByteArrayDetailed,readStreamDetailedReadBytesDetailedAsync,ReadBytesStreamDetailedAsyncTesting
206 Partial Contentmetadata mapping.200 OK.Content-Rangeand unknown total size.Breaking Changes
Checklist