Skip to content

fix(client): stream internal subprocess logs through PipeJSONStream - #1111

Merged
skevetter merged 1 commit into
mainfrom
fix/workspace-client-json-log-nesting
Aug 21, 2026
Merged

fix(client): stream internal subprocess logs through PipeJSONStream#1111
skevetter merged 1 commit into
mainfrom
fix/workspace-client-json-log-nesting

Conversation

@skevetter

@skevetter skevetter commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Workspace stop/delete logs showed doubly nested JSON:

2026-08-21T00:06:18.836-0500    INFO    {"level":"debug","ts":"2026-08-21T00:06:18.836-0500","msg":"stopping Devsy container"}

Root cause

deleteContainer/stopContainer in workspace_client.go run
devsy internal agent workspace delete|stop as a subprocess and capture
its stdout/stderr with log.Writer(log.LevelInfo). cmd/internal/agent.go
always forces internal commands to --log-output json, so that subprocess
only ever emits structured JSON log lines. log.Writer's levelWriter just
re-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 it
at 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 defer so early-return paths (e.g. agentWorkspaceCommand
failing) still drain the pipe goroutine before returning.

Verification

  • go build ./...
  • go vet ./pkg/client/clientimplementation/...
  • go test ./pkg/client/clientimplementation/...

Summary by CodeRabbit

  • Bug Fixes
    • Improved logging during workspace container deletion and stop operations.
    • Ensured operation logs are fully processed before cleanup completes.

@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit b68546d
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a88a32c10202a0008887cfc

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a59cd3ff-c267-41a8-be00-860c1ff80207

📥 Commits

Reviewing files that changed from the base of the PR and between 246de04 and b68546d.

📒 Files selected for processing (1)
  • pkg/client/clientimplementation/workspace_client.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Workspace container deletion and stopping now use log.PipeJSONStream(). Both operations close the stream and wait for its goroutine before cleanup completes.

Changes

Workspace container logging

Layer / File(s) Summary
Container operation log streams
pkg/client/clientimplementation/workspace_client.go
Container deletion and stopping replace the direct info-level writer with a JSON log stream. Each operation waits for stream completion after closing the stream.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b6854

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: streaming internal subprocess logs through PipeJSONStream to fix client log handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/workspace-client-json-log-nesting

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit b68546d
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a88a32c0a1e800008e1babd
😎 Deploy Preview https://deploy-preview-1111--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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.

Run reviewer

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>
@skevetter
skevetter force-pushed the fix/workspace-client-json-log-nesting branch from f8c22fc to b68546d Compare August 21, 2026 19:12
@skevetter
skevetter marked this pull request as ready for review August 21, 2026 20:30
@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit 317b633 into main Aug 21, 2026
83 checks passed
@skevetter
skevetter deleted the fix/workspace-client-json-log-nesting branch August 21, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant