Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@qmuntal
Copy link
Member

@qmuntal qmuntal commented Jan 30, 2026

If a users creates a client with ClientOptions{Env: []string{}} it expects that the CLI process does not inherit any variable from the current process.

Also, if ClientOptions.Env is not set (aka nil), load the current process environment variables when creating the client instead of when starting the CLI process.

Both new behaviors are aligned with what a Go users expects and with the TypeScript SDK.

@qmuntal qmuntal requested a review from a team as a code owner January 30, 2026 14:59
Copilot AI review requested due to automatic review settings January 30, 2026 14:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Go SDK's handling of the ClientOptions.Env field to properly distinguish between an unset environment (nil) and an explicitly empty environment ([]string{}). When Env is nil, the client now captures the current process's environment variables at client creation time. When Env is an empty slice, the spawned CLI process receives no environment variables.

Changes:

  • Updated documentation for the Env field in ClientOptions to clarify behavior for nil vs empty slice
  • Modified NewClient to capture environment variables when Env is nil (at client creation time)
  • Simplified startCLIServer to always use c.options.Env without additional conditional logic
  • Added comprehensive tests to verify nil, empty, and custom environment handling

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
go/types.go Enhanced documentation for the Env field to clarify nil vs empty slice behavior, following Go's exec.Cmd conventions
go/client.go Modified NewClient to capture environment at client creation when Env is nil; simplified startCLIServer to unconditionally use c.options.Env
go/client_test.go Added TestClient_EnvOptions with three test cases covering custom environment, default inheritance, and empty environment scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@friggeri friggeri added this pull request to the merge queue Jan 30, 2026
Merged via the queue into github:main with commit 6e4daa9 Jan 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants