Skip to content

SDK health check fails through server proxy due to absolute URL path in ping #3

@Kishanthan

Description

@Kishanthan

Description

When use_server_proxy=True, the server returns a proxy endpoint like:

10.170.22.187:8080/sandboxes/{id}/proxy/44772

The SDK constructs base_url as:

http://10.170.22.187:8080/sandboxes/{id}/proxy/44772

The health check in sdks/sandbox/python/src/opensandbox/api/execd/api/health/ping.py uses:

def _get_kwargs() -> dict[str, Any]:
    _kwargs: dict[str, Any] = {
        "method": "get",
        "url": "/ping",       # ABSOLUTE PATH
    }
    return _kwargs

Per RFC 3986, /ping is an absolute path that replaces the entire path component in httpx's URL resolution. So the actual request goes to:

http://10.170.22.187:8080/ping                                    <- WRONG

instead of:

http://10.170.22.187:8080/sandboxes/{id}/proxy/44772/ping         <- CORRECT

This means the health check request never reaches the sandbox pod — it hits a non-existent route on the server.

Scope of Impact

This affects all execd API endpoints that use absolute paths through the openapi-generated client:

  • ping.py — health check
  • Any other endpoints in sdks/sandbox/python/src/opensandbox/api/execd/api/ using "url": "/..." pattern

Command execution is NOT affected because CommandsAdapterSync uses _get_execd_url() which manually constructs the full URL:

def _get_execd_url(self, path: str) -> str:
    return f"{self.connection_config.protocol}://{self.execd_endpoint.endpoint}{path}"

This bypasses httpx's base_url resolution entirely.

Steps to Reproduce

  1. Deploy OpenSandbox server with Kubernetes runtime
  2. From a remote machine:
conn = ConnectionConfigSync(
    domain="<server-ip>:8080",
    use_server_proxy=True,
)
sandbox = SandboxSync.create(
    "python:3.11-slim",
    connection_config=conn,
)
# Hangs on health check, then times out

Workaround

Use skip_health_check=True. Command execution still works from remote nodes because it uses manual URL construction.

sandbox = SandboxSync.create(
    "python:3.11-slim",
    connection_config=conn,
    skip_health_check=True,
)
sandbox.commands.run("echo hello")  # This works

Suggested Fix

Change the URL in ping.py (and other affected execd API endpoints) from absolute to relative path:

# Before
"url": "/ping"

# After
"url": "ping"

Alternatively, refactor the health adapter to use manual URL construction (like the command adapter does) instead of relying on httpx base_url resolution.

Affected Versions

  • python/sandbox/v0.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions