Skip to content

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

Draft
skevetter wants to merge 1 commit into
mainfrom
fix/workspace-client-json-log-nesting
Draft

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

Conversation

@skevetter

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/...

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).
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

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

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c45b976-1588-4207-bbdd-e5920847cc3d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 canceled.

Name Link
🔨 Latest commit f8c22fc
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a87e40327bf5a0008a2fb9a

@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.

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