Add Go SDK#254
Conversation
|
/cubebot review |
|
Claude finished @fslongjin's task in 1m 44s —— View job Go SDK Code ReviewOverall the Go SDK is well-structured with clean API design, comprehensive test coverage (including edge cases), and thorough documentation. Below are specific findings organized by severity. Bugs / Correctness Issues1. Fragile exit code parsing in The exit code is parsed from the last line of stdout output. If a command's output happens to end with a line containing only an integer, that line will be silently consumed as the exit code rather than returned as output. // If a user runs: echo 42
// result.Stdout will be "" (empty) and result.ExitCode will be 42
// even though the actual exit code was 0This is a known pattern carried over from the E2B Python SDK design, but it's worth documenting this limitation. Consider evaluating whether a different encoding scheme (e.g., a delimiter or separate file descriptor) would be more robust for production use. 2. Silent JSON marshal error discard ( raw, _ := json.Marshal(payload)This silently discards a marshaling error. While Design / API Concerns3. Hardcoded HTTP scheme for data-plane requests ( req, err := http.NewRequestWithContext(ctx, http.MethodPost, "http://"+s.GetHost(JupyterPort)+"/execute", bytes.NewReader(raw))The 4. Python Minor (Style / Conventions)5. Error message capitalization ( return "", fmt.Errorf("Failed to read %s: %s", path, execution.Error.Value)Go convention requires error messages to start with lowercase. Should be 6. func errorFromRunCode(_ *Execution, err error) error {
return err
}This discards the Strengths
SummaryThe SDK is production-quality in its structure and testing rigor. The exit code parsing fragility in |
|
tinklone
left a comment
There was a problem hiding this comment.
CR Review: New Commits (6b03855 + 17aad98)
Summary: Refactored Commands/Files from Python RunCode hack to native envd Process API + HTTP File API. Significant improvement in correctness and maintainability.
✅ Highlights
- Architecture:
CommandsandFilesnow use independentprocessStarter/fileReaderinterfaces instead of sharedcodeRunner— cleaner SRP - Correctness: Exit code from
EndEventfield instead of fragile stdout last-line parsing - Connect protocol: Proper envelope parsing, end-stream error handling, compressed flag rejection
- ProxyScheme: Smart default (port 443 → https, else http) with explicit override support
- Test coverage: New integration + unit tests with clean mock boundaries
🟡 Minor Suggestions (non-blocking)
| # | Location | Issue | Suggestion |
|---|---|---|---|
| 1 | envd.go:186 |
io.ErrUnexpectedEOF treated as normal EOF in readConnectEnvelope |
Should return error for mid-stream truncation (only io.EOF is clean end) |
| 2 | envd.go:167 |
No break after sawEnd = true in stream parse loop |
After EndEvent, remaining frames are unexpected — consider breaking early |
| 3 | envd.go:81 |
Dual field ExitCode + ExitCodeSnake without comment |
Add a brief comment explaining why both exist (backend version compat?) |
| 4 | commands.go:21 |
Empty map init for nil Envs | If envd accepts "envs":null, this is unnecessary; if not, keep it but add a comment |
❓ Questions for Author
- 64MB envelope limit: Could a large stdout
catOOM? Consider streaming for large outputs. /bin/bash -l -c: Login shell loads.bash_profileetc. Is this intentional? May add latency in some images.readFileunbounded:io.ReadAllwithoutLimitReader— risk for very large files?
Verdict
LGTM — core logic correct, tests thorough. Minor items can be follow-up.
|
Hi @wangchenglong-hj 👋 CI has two failing checks, one of which requires action on your side: ❌ DCO (Developer Certificate of Origin)All 3 commits are missing the To fix: git rebase --signoff HEAD~3 && git push --force-with-leaseThis will automatically append to each commit message: Reference: https://developercertificate.org/
|
|
Could you please squash these commits into a single one? Thanks! @wangchenglong-hj |
17aad98 to
0c6d83b
Compare
Add a standalone standard-library Go SDK for CubeSandbox with lifecycle management, command execution, file reads, proxy transport, README, unit tests, and opt-in integration tests. Route command execution through envd process APIs, return exit codes through execution results, support configurable data-plane proxy scheme, and use envd HTTP file APIs for file reads. Assisted-by: Codex:GPT-5 Signed-off-by: Nemo <ssdn@vip.qq.com>
0c6d83b to
6e52542
Compare
Add a standalone standard-library Go SDK for CubeSandbox with lifecycle, execution, command, file read, proxy transport, README, unit tests, and opt-in integration tests.
Autonomously-by: Codex:GPT-5