Skip to content

Commit e4a1e0c

Browse files
edburnsCopilot
andcommitted
Fix InProcess test parity: respect explicit subprocess options over env var
- resolveDefaultConnection: when cliUrl, cliPath, or port are explicitly set, fall back to subprocess transport even if COPILOT_SDK_DEFAULT_CONNECTION is 'inprocess'. Explicit options take precedence over the env var default. - validateEnvironmentOptions: check isEmpty() in addition to null, since setEnvironment(null) clears the map rather than nulling the field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7a38160-a65e-4d0c-9087-4f28da2a51b8
1 parent f22b4af commit e4a1e0c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

java/sdk/src/main/java/com/github/copilot/CopilotClient.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ private static RuntimeConnection resolveDefaultConnection(CopilotClientOptions o
259259
static RuntimeConnection resolveDefaultConnection(CopilotClientOptions options, String envValue) {
260260
if (envValue != null && !envValue.isEmpty()) {
261261
if ("inprocess".equalsIgnoreCase(envValue)) {
262+
// Explicit subprocess options take precedence over the env var default.
263+
if (options.getCliUrl() != null && !options.getCliUrl().isEmpty()) {
264+
return inferConnectionFromOptions(options);
265+
}
266+
if (options.getCliPath() != null && !options.getCliPath().isEmpty()) {
267+
return inferConnectionFromOptions(options);
268+
}
269+
if (options.getPort() != 0) {
270+
return inferConnectionFromOptions(options);
271+
}
262272
return RuntimeConnection.forInProcess();
263273
}
264274
if (!"stdio".equalsIgnoreCase(envValue)) {
@@ -390,7 +400,7 @@ private static void validateEnvironmentOptions(CopilotClientOptions options, Run
390400
return;
391401
}
392402

393-
rejectInProcessOption("Environment", options.getEnvironment() != null,
403+
rejectInProcessOption("Environment", options.getEnvironment() != null && !options.getEnvironment().isEmpty(),
394404
"set the variables on the host process environment instead");
395405
rejectInProcessOption("Telemetry", options.getTelemetry() != null,
396406
"configure telemetry through the host process environment instead");

0 commit comments

Comments
 (0)