feat(sandbox): add sandbox module#466
Conversation
Add an E2B-style sandbox client with lifecycle, envd commands, filesystem, git, template, resource, and injection-rule support. Include .env-based examples plus unit and integration coverage for the new sandbox surface.
Add PTY, command streaming, filesystem watcher/write_files, Git helpers and credential authentication APIs for the sandbox module. Expand sandbox unit/integration tests, runnable examples, and the E2B Python SDK differences document including remote Git push coverage.
Keep the sandbox runtime, test, and example changes tracked while removing the generated E2B differences document from the submitted branch.
Return command handles from a streaming start path so background commands do not wait for process completion. Bound wait_for_ready health probes with per-request timeouts and cover both review fixes with tests.
Add E2B-style filesystem info objects, stream reads, IO writes, Git structured status and branches, Git typed exceptions, ReadyCmd helpers, is_running, and compatible Git config signatures. Keep Volume, Snapshot, and MCP gateway behavior out of scope.
Use temporary remote credential URLs for authenticated push and pull, restoring the original remote after success or failure. Forward request_timeout/timeout through filesystem file transfers and cover the behavior with sandbox tests.
Handle empty envd streams, tighten sandbox exception handling, refresh traffic tokens, and prevent stale paginator tokens. Add regression coverage for reviewer feedback and keep external Git TLS failures from failing integration runs.
Encode Git credentials safely, handle wait/read/stdin edge cases, and serialize metrics IDs consistently. Add regression tests for the second PR feedback round.
Avoid credential exposure in git authentication, report remote restore failures, use Python 2 compatible text handling, and set a default client timeout. Cover the reviewer feedback with focused sandbox regression tests.
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Sandbox service integration to the Qiniu Python SDK, including modules for client API requests, command execution, filesystem operations, Git integration, PTY allocation, resource mounting, and template builds, along with extensive examples and tests. The review feedback highlights several critical issues: the lifecycle parameter is parsed but omitted from the sandbox creation request body, and allow_internet_access should use camelCase to match other API fields. Additionally, Python 2 compatibility issues in _decode_bytes could trigger UnicodeDecodeError, and unhandled exceptions in base64.b64decode might cause crashes. Finally, there are security concerns regarding the cleanup of temporary Git credentials for background commands if wait() is not called, and a parsing edge case in _is_legacy_config_call when repository paths contain dots.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Add the Qiniu Sandbox Python SDK surface from PR #466 as a single mainline commit.
概述
.env的示例配置、单元测试和集成测试;集成测试与示例已覆盖远端 Git push 场景。验证
python3 -m flake8 examples/sandbox_*.py qiniu/services/sandbox tests/cases/test_services/test_sandbox --max-line-length=160python3 -m compileall -q examples/sandbox_*.py qiniu/services/sandbox tests/cases/test_services/test_sandboxenv QINIU_SANDBOX_API_KEY= QINIU_API_KEY= E2B_API_KEY= QINIU_SANDBOX_ACCESS_KEY= QINIU_SANDBOX_SECRET_KEY= GIT_REPO_URL= GIT_USERNAME= GIT_PASSWORD= GITHUB_TOKEN= python3 -m pytest tests/cases/test_services/test_sandbox/test_client.py tests/cases/test_services/test_sandbox/test_config.py tests/cases/test_services/test_sandbox/test_envd.py tests/cases/test_services/test_sandbox/test_example_config.py -q->110 passed28086731528已全部通过。