fix(client): stream internal subprocess logs through PipeJSONStream - #1111
Conversation
✅ Deploy Preview for devsydev canceled.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughWorkspace container deletion and stopping now use ChangesWorkspace container logging
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change prevents workspace stop/delete subprocess logs from being double-encoded while preserving their original log level and message; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for images-devsy-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
deleteContainer/stopContainer capture stdout/stderr from `devsy internal agent workspace delete|stop`, which cmd/internal/agent.go always forces to --log-output json. Piping that through log.Writer re-logged each raw JSON line verbatim as a message, producing doubly nested JSON log records. Switch to log.PipeJSONStream, which unwraps each line and re-emits it at its original level, matching the existing pattern used for other internal JSON-emitting subprocesses (ssh.go, gpg_tunnel.go, proxy_client.go). Signed-off-by: Samuel K <skevetter@pm.me>
f8c22fc to
b68546d
Compare
|
Tick the box to add this pull request to the merge queue (same as
|
Problem
Workspace stop/delete logs showed doubly nested JSON:
Root cause
deleteContainer/stopContainerinworkspace_client.gorundevsy internal agent workspace delete|stopas a subprocess and captureits stdout/stderr with
log.Writer(log.LevelInfo).cmd/internal/agent.goalways forces internal commands to
--log-output json, so that subprocessonly ever emits structured JSON log lines.
log.Writer'slevelWriterjustre-logs each captured line verbatim as a message — wrapping the child's
already-JSON line inside another log record.
Fix
Use
log.PipeJSONStream()instead, which parses each line and re-emits itat its original level/message. This is the same pattern already used for
other internal JSON-emitting subprocesses (
cmd/workspace/ssh.go,cmd/workspace/gpg_tunnel.go,pkg/client/clientimplementation/proxy_client.go).Close+drain moved to a
deferso early-return paths (e.g.agentWorkspaceCommandfailing) still drain the pipe goroutine before returning.
Verification
go build ./...go vet ./pkg/client/clientimplementation/...go test ./pkg/client/clientimplementation/...Summary by CodeRabbit