Repository navigation
Closed
Labels
Description
Summary
Sandbox workspace persistence via file API (GET /download/{path}) fails silently when the gateway returns HTTP 307 redirect, causing workspace snapshots to be lost after sandbox teardown.
Root Cause
SandboxConnectorexplicitly configuresHttpClient.Redirect.NEVER(lines 93, 117 inSandboxConnector.java)Filesystem.read()treats any non-2xx response (including 307) as failure (lines 124-128 inFilesystem.java)- Paths like
.agentscope-tmp/ws-persist-*.tarare URL-encoded →%2F→ triggers gateway normalization redirect - The exception is caught and logged as WARN in
SandboxManager.release(), but COS snapshot upload never happens
Impact
- Silent data loss: users' workspace changes are lost after sandbox eviction
- Affects all deployments where sandbox access goes through a gateway that returns 307 for paths with
%2F - Only
downloadAPI is proven affected;upload(POST with no path parameter) likely unaffected
Reproduction
curl -vk "{apiUrl}/download/.agentscope-tmp%2Fsome-file" -o /dev/null
# Observe: 307 redirect → Location header with decoded pathProposed Fix
Change SandboxConnector.java (both constructors):
.followRedirects(HttpClient.Redirect.NEVER) → .followRedirects(HttpClient.Redirect.NORMAL)Safety verification:
NORMALdoes not follow redirects for requests with body (POST exec, multipart upload) → no regressionNORMALdoes not downgrade HTTPS→HTTP- Download endpoint has no auth → losing auth header on redirect is safe
Workaround (application layer)
Override KubernetesSandbox.doPersistWorkspace() to catch SandboxRequestException and fall back to exec-based transfer (tar -cf - | base64).
Environment
- AgentScope Java: 2.0.1 (verified also present in main branch 2.0.3-SNAPSHOT)
- Deployment: Kubernetes sandbox with gateway routing
Evidence Chain
| Evidence | Source Location | Status |
|---|---|---|
HttpClient configured with Redirect.NEVER |
SandboxConnector.java:93, 117 |
✅ Confirmed |
| Non-2xx treated as failure | Filesystem.java:124-128 |
✅ Confirmed throws SandboxRequestException |
Path URL encoding produces %2F |
Filesystem.java:121 calls percentEncode() |
✅ Confirmed |
| Retry whitelist excludes 3xx | SandboxConnector.java:50 |
✅ Only 500/502/503/504 |
Discovered through production run log analysis showing:
SandboxLifecycleMiddleware.releaseForCall
→ SandboxManager.release
→ KubernetesSandbox.doPersistWorkspace
→ Filesystem.read
→ HTTP 307 → "Download failed (status=307)" → SandboxRequestException
→ COS snapshot upload not executed
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(sandbox-kubernetes): follow redirects so file API downloads survi…