Skip to content

[go] - Client does not capture CLI stderr, making startup failures opaque #862

@claudiogodoy99

Description

@claudiogodoy99

Client does not capture CLI stderr, making startup failures opaque

When the CLI process exits during startup, the SDK reports:

panic: process exited unexpectedly
        failed to kill CLI process: os: process already finished

There is no indication of why the process exited. The actual error (e.g. version incompatibility, auth failure) is written to stderr, which the SDK never captures.

Cause

  1. client.go never sets exec.Cmd.Stderr, so CLI stderr is discarded.
  2. internal/jsonrpc2/jsonrpc2.go has a race in SetProcessDone — it copies the process error in a goroutine that can run after Request() already checked for it, so even exit code info can be missed.

Suggested fix

  • Set c.process.Stderr = &bytes.Buffer{} and include its contents in the error from monitorProcess.
  • In SetProcessDone, store the error pointer directly instead of copying it asynchronously.

Environment

  • SDK: github.com/github/copilot-sdk/go (source, commit:ea90f076091371810c66d05590f65e2863f79bdf main)
  • Go: 1.24.5 linux/amd64
  • OS: Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (WSL2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions