Skip to content

fix(sdk-java): pass custom env to CLI process#3543

Merged
LaZzyMan merged 1 commit into
QwenLM:mainfrom
lawrence3699:fix/java-sdk-env-options-3536
Apr 24, 2026
Merged

fix(sdk-java): pass custom env to CLI process#3543
LaZzyMan merged 1 commit into
QwenLM:mainfrom
lawrence3699:fix/java-sdk-env-options-3536

Conversation

@lawrence3699

Copy link
Copy Markdown
Contributor

TLDR

Fixes #3536.

Apply TransportOptions.setEnv(...) to the Java SDK ProcessBuilder before starting the Qwen Code CLI subprocess. The adapter already merges System.getenv() with the caller-provided env map, but the merged map was never wired into the child process.

Screenshots / Video Demo

Terminal evidence:

Before this change, the focused regression failed because the child process printed an empty value:

expected: <from-set-env> but was: <>

After this change:

mvn -Dtest=ProcessTransportTest#shouldPassCustomEnvToProcess test
# BUILD SUCCESS; Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Dive Deeper

TransportOptionsAdapter#addDefaultTransportOptions() already builds the intended subprocess environment by starting from System.getenv() and overlaying TransportOptions.getEnv().

ProcessTransport#start() now copies that handled env map into processBuilder.environment() before start(), so Java SDK callers can pass values such as proxy, sandbox, model, or other runtime configuration variables to the CLI process as documented.

Reviewer Test Plan

  1. From packages/sdk-java/qwencode, run mvn -Dtest=ProcessTransportTest#shouldPassCustomEnvToProcess test.
  2. Confirm the new test creates a temporary executable, passes QWEN_SDK_TEST_ENV through TransportOptions.setEnv(...), and reads the value from the child process output.
  3. Inspect ProcessTransport#start() and confirm the handled env map is applied before processBuilder.start().

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker - - -
Podman - - -
Seatbelt - - -

Java SDK validation run on macOS:

mvn -Dtest=ProcessTransportTest#shouldPassCustomEnvToProcess test
mvn -DskipTests test
mvn checkstyle:check
git diff --check

All passed. I did not run npm run preflight; this patch is limited to the Maven-based Java SDK package, and the existing package test file includes live-CLI tests that can depend on local auth/provider state.

Linked issues / bugs

Fixes #3536

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review

@LaZzyMan LaZzyMan merged commit 3e74a33 into QwenLM:main Apr 24, 2026
13 checks passed
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
Co-authored-by: lawrence3699 <lawrence3699@users.noreply.github.com>
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.

[qwencode-sdk-java 0.0.3-alpha] TransportOptions.setEnv() is silently dropped — env never reaches the CLI subprocess

3 participants