Repository navigation
fix(opensandbox): send the API key on proxied execd routes - #2462
Merged
Merged
Conversation
The SDK's execd-facing clients (health ping, commands, files) attach only ConnectionConfig.headers; the api_key field is used by the lifecycle API clients alone. On servers that enforce API-key auth on /proxy/* routes, every health ping during Sandbox.create therefore returns 401 (MISSING_API_KEY) even though the key is configured, and creation spins until ready_timeout before failing. Exec and file operations through the proxy fail the same way. Inject the key into ConnectionConfig.headers in server-proxy mode so all proxied execd requests authenticate. Direct-endpoint mode deliberately stays keyless: the sandbox endpoint runs untrusted code and must never see the key. Harmless on servers that do not enforce proxy auth. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Hemil Desai <hemild@nvidia.com>
hemildesai
marked this pull request as ready for review
August 10, 2026 22:31
Contributor
Author
|
/claude review |
bxyu-nvidia
approved these changes
Aug 10, 2026
Contributor
|
SHIP — LGTM, no reliability concerns. The fix is correct and minimal: injecting |
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
On OpenSandbox deployments that enforce API-key auth on the server's
/proxy/*routes, every proxied execd request fails with401 {"code":"MISSING_API_KEY"}even thoughapi_keyis configured — because the SDK wires the key only into the lifecycle-API clients. The execd-facing clients (health ping, commands, filesystem) send onlyConnectionConfig.headers, which the provider never populated.The visible symptom is nasty:
Sandbox.createreturns202, endpoint lookups return200, but the SDK's internal health wait pings/proxy/44772/pingkeyless, gets401forever, and creation spins untilready_timeoutbefore failing withSandboxReadyTimeoutException. Exec and file operations through the proxy fail the same way.Change
In
_connection_config, whenuse_server_proxyis enabled and anapi_keyis configured, also pass the key as theOPEN-SANDBOX-API-KEYheader viaConnectionConfig.headers— the SDK merges those headers into every execd client, so proxied pings/execs authenticate.Scoped deliberately:
Testing
Unit: extended
test_connection_config_and_image_policy— proxy mode + api_key →headers={"OPEN-SANDBOX-API-KEY": ...}present; direct mode → noheadersinjected.End-to-end A/B against a live enforcing deployment (provider → SDK 0.1.15 → server proxy), same script, only the provider tree differing:
SandboxReadyTimeoutException— health check false continuously (keyless pings 401), create fails after every retryexec("echo e2e-ok")→ rc=0stdout='e2e-ok', clean close🤖 Generated with Claude Code