fix(client): stream internal subprocess logs through PipeJSONStream - #1111
fix(client): stream internal subprocess logs through PipeJSONStream#1111skevetter wants to merge 1 commit into
Conversation
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).
✅ Deploy Preview for devsydev canceled.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 canceled.
|
|
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.
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/...