Sidecar ignores VS Code proxy settings and `HTTPS_PROXY`: OAuth token requests fail behind an HTTP proxy

Open
#3,461 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java, typescript, vscode

Research direction

Start with src/sidecar/sidecarManager.ts and src/sidecar/utils.ts, where the issue says the sidecar is spawned without proxy settings; read the spawn() call and the existing environment construction. Check how VS Code proxy settings and proxy environment variables map to Java system properties, including noProxy behavior and the stated credential handling. Done means OAuth token requests use the configured proxy while hosts in the bypass list remain directly reachable.

Written by the indexing model from the issue text.

Description

needs triage
Code of Conduct
  • I agree to follow this project's Code of Conduct
On what operating system are you seeing the problem?

Windows (x64)

VS Code version
  • Confluent extension 2.3.1, ide-sidecar 0.271.0 (native, Windows)
  • VS Code 1.142.0, Windows 11
  • Outbound HTTPS only via an authenticating HTTP proxy
  • Kafka cluster and Schema Registry are reachable directly (listed in NO_PROXY)
Version of Confluent extension

2.3.1

To Reproduce
Summary

In networks where public hosts are only reachable through an HTTP proxy, direct connections that use
OAuth cannot be established. The sidecar tries to reach the identity provider's token endpoint
directly and fails, even though VS Code's http.proxy setting and the HTTPS_PROXY / HTTP_PROXY
environment variables are configured.

Steps to reproduce
  1. Configure http.proxy in VS Code and/or set HTTPS_PROXY, HTTP_PROXY, NO_PROXY.
  2. Create a direct connection to Kafka and Schema Registry with OAuth credentials
    (tokens_url pointing to a public identity provider, e.g. https://idp.example.com/oauth2/token).
  3. Observe the connection status.
Current vs. Expected behavior
Expected

The sidecar sends the token request through the configured proxy, and connects to hosts listed in
NO_PROXY / http.noProxy directly.

Actual

Both Kafka and Schema Registry fail. Sidecar log (hostnames anonymized):

Unable to connect to Kafka cluster at kafka.example.internal:9093: An internal error occurred while
retrieving token from callback handler [javax.security.auth.login.LoginException]

Failed to connect to Schema Registry: idp.example.com [java.net.UnknownHostException]
    at org.apache.kafka.common.security.oauthbearer.internals.secured.HttpAccessTokenRetriever.post(...)
    at io.confluent.kafka.schemaregistry.client.security.bearerauth.oauth.CachedOauthTokenRetriever.getToken(...)
Root cause

The sidecar is a native Java executable. Java's networking stack ignores HTTPS_PROXY /
HTTP_PROXY and only honors the http(s).proxyHost, http(s).proxyPort and http.nonProxyHosts
system properties. The extension spawns the sidecar without any arguments and does not translate
VS Code's proxy settings
(startSidecar() in sidecarManager.ts,
constructSidecarEnv() in utils.ts).
There is also no extension setting or connection field to configure a proxy.

Verified workaround

Starting the sidecar with Java proxy system properties fixes the problem:

ide-sidecar-<version>-runner.exe
  -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=8080
  -Dhttp.proxyHost=proxy.example.com  -Dhttp.proxyPort=8080
  -Dhttp.nonProxyHosts=localhost|127.*|[::1]

With this (applied as a local patch to the spawn() call), the OAuth token request goes through the
proxy, including proxy authentication, and the Kafka connection succeeds.

Proposed fix

Translate VS Code's proxy settings into Java system properties when spawning the sidecar:

  • proxy from http.proxy, falling back to HTTPS_PROXY / https_proxy / HTTP_PROXY / http_proxy
  • http.nonProxyHosts from http.noProxy + NO_PROXY (.example.com becomes *.example.com);
    loopback addresses are always included, so the extension can still reach the sidecar
  • no arguments (unchanged behavior) if no proxy is configured, http.proxySupport is off, or
    NO_PROXY is *
  • credentials in the proxy URL (user:pass@) are not passed, so they don't appear in the process
    list; a warning is logged instead
Relevant log output
Full sidecar log (anonymized)
08:01:23.500 ERROR [DirectConnectionState] Unable to connect to Kafka cluster at kafka.example.internal:9093: An internal error occurred while retrieving token from callback handler
javax.security.auth.login.LoginException: An internal error occurred while retrieving token from callback handler
    at org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule.identifyToken(OAuthBearerLoginModule:320)
    at org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule.login(OAuthBearerLoginModule:302)
    at javax.security.auth.login.LoginContext.invoke(LoginContext:754)
    at javax.security.auth.login.LoginContext$4.run(LoginContext$4:678)
    at javax.security.auth.login.LoginContext$4.run(LoginContext$4:676)
    at java.security.AccessController.executePrivileged(AccessController:114)
    at java.security.AccessController.doPrivileged(AccessController:714)
    at javax.security.auth.login.LoginContext.invokePriv(LoginContext:676)
    at javax.security.auth.login.LoginContext.login(LoginContext:587)
    at org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin.login(ExpiringCredentialRefreshingLogin:205)
    at org.apache.kafka.common.security.oauthbearer.internals.OAuthBearerRefreshingLogin.login(OAuthBearerRefreshingLogin:151)
    at org.apache.kafka.common.security.authenticator.LoginManager.<init>(LoginManager:69)
    at org.apache.kafka.common.security.authenticator.LoginManager.acquireLoginManager(LoginManager:116)
    at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder:170)
    at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders:188)
    at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders:79)
    at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils:120)
    at org.apache.kafka.clients.ClientUtils.createNetworkClient(ClientUtils:224)
    at org.apache.kafka.clients.admin.KafkaAdminClient.createInternal(KafkaAdminClient:550)
    at org.apache.kafka.clients.admin.Admin.create(Admin:143)
    at org.apache.kafka.clients.admin.AdminClient.create(AdminClient:49)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.createAdminClient(DirectConnectionState:325)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.withAdminClient(DirectConnectionState:286)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.getKafkaConnectionStatus(DirectConnectionState:168)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.doRefreshStatus(DirectConnectionState:153)
    ... 18 more

08:01:33.516 INFO [DirectConnectionState] Failed to connect to the Schema Registry at https://schema-registry.example.internal: Error while fetching Oauth Token for Schema Registry: Failed to Retrieve OAuth Token for Schema Registry

08:01:33.516 ERROR [DirectConnectionState] Failed to connect to Schema Registry: idp.example.com
java.net.UnknownHostException: idp.example.com
    at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl:567)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl:327)
    at java.net.Socket.connect(Socket:751)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl:304)
    at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl:181)
    at sun.net.NetworkClient.doConnect(NetworkClient:183)
    at sun.net.www.http.HttpClient.openServer(HttpClient:531)
    at sun.net.www.http.HttpClient.openServer(HttpClient:636)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient:377)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection:193)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection:1237)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection:1123)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection:179)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl:141)
    at org.apache.kafka.common.security.oauthbearer.internals.secured.HttpAccessTokenRetriever.handleInput(HttpAccessTokenRetriever:235)
    at org.apache.kafka.common.security.oauthbearer.internals.secured.HttpAccessTokenRetriever.post(HttpAccessTokenRetriever:200)
    at org.apache.kafka.common.security.oauthbearer.internals.secured.HttpAccessTokenRetriever.lambda$retrieve$0(HttpAccessTokenRetriever:176)
    at org.apache.kafka.common.security.oauthbearer.internals.secured.Retry.execute(Retry:72)
    at org.apache.kafka.common.security.oauthbearer.internals.secured.HttpAccessTokenRetriever.retrieve(HttpAccessTokenRetriever:167)
    at io.confluent.kafka.schemaregistry.client.security.bearerauth.oauth.CachedOauthTokenRetriever.getToken(CachedOauthTokenRetriever:64)
    at io.confluent.kafka.schemaregistry.client.security.bearerauth.oauth.OauthCredentialProvider.getBearerToken(OauthCredentialProvider:54)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.setAuthRequestHeaders(RestService:2033)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.buildConnection(RestService:506)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest(RestService:441)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.lambda$httpRequest$0(RestService:652)
    at io.confluent.kafka.schemaregistry.client.rest.RetryExecutor.retry(RetryExecutor:53)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService:652)
    at io.confluent.idesidecar.restapi.clients.SidecarSchemaRegistryClient.httpRequest(SidecarSchemaRegistryClient:53)
    at io.confluent.idesidecar.restapi.clients.SchemaRegistryClient.getSchemaTypes(SchemaRegistryClient:32)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.lambda$getSchemaRegistryConnectionStatus$4(DirectConnectionState:225)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.withSchemaRegistryClient(DirectConnectionState:351)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.getSchemaRegistryConnectionStatus(DirectConnectionState:222)
    at io.confluent.idesidecar.restapi.connections.DirectConnectionState.doRefreshStatus(DirectConnectionState:154)
    ... 18 more

After starting the sidecar with the Java proxy system properties (plus a trust store for the private CA):

08:28:11.945 INFO [ConnectionState] Updated status for connection ID=<id>. Original spec: ConnectionStatus[ccloud=null, kafkaCluster=KafkaClusterStatus[state=ATTEMPTING, user=null, errors=null], schemaRegistry=null], Updated spec: ConnectionStatus[ccloud=null, kafkaCluster=KafkaClusterStatus[state=SUCCESS, user=null, errors=null], schemaRegistry=null], Last updated: 2026-10-21T06:28:11.945185400Z
Which area(s) are affected? (Select all that apply)

Connections

Additional context
src/sidecar/utils.ts
/** The proxy-related VS Code `http.*` settings relevant for the sidecar process. */
export interface SidecarProxySettings {
  proxy?: string;
  noProxy?: string[];
  proxySupport?: string;
}

/** Read the proxy-related VS Code settings for the sidecar process. */
export function getSidecarProxySettings(): SidecarProxySettings {
  const config = vscode.workspace.getConfiguration("http");
  return {
    proxy: config.get<string>("proxy"),
    noProxy: config.get<string[]>("noProxy"),
    proxySupport: config.get<string>("proxySupport"),
  };
}

/**
 * Construct the command line arguments for the sidecar process.
 *
 * The sidecar is a native Java executable, which ignores `HTTPS_PROXY` / `HTTP_PROXY` and only
 * honors the Java networking system properties. Translate VS Code's proxy settings (falling back
 * to the standard environment variables) into those properties.
 * @param settings The VS Code proxy settings, parameterized for test purposes.
 * @param env The current environment, parameterized for test purposes.
 * @returns The arguments for the sidecar process; empty if no proxy is to be used.
 */
export function constructSidecarArgs(
  settings: SidecarProxySettings,
  env: NodeJS.ProcessEnv,
): string[] {
  if (settings.proxySupport === "off") {
    return [];
  }
  const rawProxy =
    settings.proxy || env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy;
  if (!rawProxy) {
    return [];
  }
  const noProxyEntries = [
    ...(settings.noProxy ?? []),
    ...(env.NO_PROXY ?? env.no_proxy ?? "").split(","),
  ].map((entry) => entry.trim());
  if (noProxyEntries.includes("*")) {
    return [];
  }

  let proxyUrl: URL;
  try {
    proxyUrl = new URL(rawProxy.includes("://") ? rawProxy : `http://${rawProxy}`);
  } catch {
    logger.warn("Ignoring invalid proxy URL for the sidecar process");
    return [];
  }
  if (proxyUrl.username || proxyUrl.password) {
    // Never pass credentials on the command line, where they would be visible in the process list.
    logger.warn("Proxy credentials are not passed to the sidecar process");
  }

  const host = proxyUrl.hostname;
  const port = proxyUrl.port || (proxyUrl.protocol === "https:" ? "443" : "80");
  logger.info(`Sidecar will use proxy ${host}:${port}`);
  return [
    `-Dhttps.proxyHost=${host}`,
    `-Dhttps.proxyPort=${port}`,
    `-Dhttp.proxyHost=${host}`,
    `-Dhttp.proxyPort=${port}`,
    `-Dhttp.nonProxyHosts=${toJavaNonProxyHosts(noProxyEntries)}`,
  ];
}

/**
 * Convert `NO_PROXY`-style entries into Java's `http.nonProxyHosts` format. Loopback addresses
 * are always included, so the extension can still reach the sidecar.
 */
export function toJavaNonProxyHosts(entries: string[]): string {
  const hosts = new Set(["localhost", "127.*", "[::1]"]);
  for (const rawEntry of entries) {
    // Java does not support ports or CIDR ranges in http.nonProxyHosts.
    const entry = rawEntry.trim().replace(/^([^\[\]:]+):\d+$/, "$1");
    if (!entry || entry.includes("/")) {
      continue;
    }
    if (entry.startsWith(".")) {
      hosts.add(`*${entry}`);
    } else {
      hosts.add(entry);
      if (!entry.startsWith("*") && !/^[\d.]+$/.test(entry)) {
        hosts.add(`*.${entry}`);
      }
    }
  }
  return [...hosts].join("|");
}
src/sidecar/sidecarManager.ts
 import {
   checkSidecarFile,
+  constructSidecarArgs,
   constructSidecarEnv,
+  getSidecarProxySettings,
   isProcessRunning,
         const sidecar_env = constructSidecarEnv(process.env);
+        const sidecar_args = constructSidecarArgs(getSidecarProxySettings(), process.env);
 ...
-            sidecarProcess = spawn(executablePath, [], {
+            sidecarProcess = spawn(executablePath, sidecar_args, {
               detached: true,
src/sidecar/utils.test.ts
import {
  constructSidecarArgs,
  // ...existing imports
  toJavaNonProxyHosts,
} from "./utils";

describe("constructSidecarArgs()", () => {
  const proxyArgs = (host: string, port: string) => [
    `-Dhttps.proxyHost=${host}`,
    `-Dhttps.proxyPort=${port}`,
    `-Dhttp.proxyHost=${host}`,
    `-Dhttp.proxyPort=${port}`,
  ];

  it("returns no arguments if no proxy is configured", () => {
    assert.deepStrictEqual(constructSidecarArgs({}, {}), []);
  });

  it("uses the http.proxy setting before the environment variables", () => {
    const args = constructSidecarArgs(
      { proxy: "http://proxy.example.com:3128" },
      { HTTPS_PROXY: "http://other.example.com:8080" },
    );
    assert.deepStrictEqual(args.slice(0, 4), proxyArgs("proxy.example.com", "3128"));
  });

  it("falls back to HTTPS_PROXY, then HTTP_PROXY", () => {
    assert.deepStrictEqual(
      constructSidecarArgs(
        {},
        { HTTPS_PROXY: "http://a.example.com:1", HTTP_PROXY: "http://b.example.com:2" },
      ).slice(0, 4),
      proxyArgs("a.example.com", "1"),
    );
    assert.deepStrictEqual(
      constructSidecarArgs({}, { HTTP_PROXY: "http://b.example.com:2" }).slice(0, 4),
      proxyArgs("b.example.com", "2"),
    );
  });

  it("accepts a proxy without scheme and defaults the port by scheme", () => {
    assert.deepStrictEqual(
      constructSidecarArgs({ proxy: "proxy.example.com:8080" }, {}).slice(0, 4),
      proxyArgs("proxy.example.com", "8080"),
    );
    assert.deepStrictEqual(
      constructSidecarArgs({ proxy: "http://proxy.example.com" }, {}).slice(0, 4),
      proxyArgs("proxy.example.com", "80"),
    );
    assert.deepStrictEqual(
      constructSidecarArgs({ proxy: "https://proxy.example.com" }, {}).slice(0, 4),
      proxyArgs("proxy.example.com", "443"),
    );
  });

  it("returns no arguments if http.proxySupport is off", () => {
    assert.deepStrictEqual(
      constructSidecarArgs({ proxy: "http://proxy.example.com:8080", proxySupport: "off" }, {}),
      [],
    );
  });

  it("returns no arguments if NO_PROXY is *", () => {
    assert.deepStrictEqual(
      constructSidecarArgs({}, { HTTPS_PROXY: "http://proxy.example.com:8080", NO_PROXY: "*" }),
      [],
    );
  });

  it("ignores an invalid proxy URL", () => {
    assert.deepStrictEqual(constructSidecarArgs({ proxy: "http://[invalid" }, {}), []);
  });

  it("does not pass proxy credentials", () => {
    const args = constructSidecarArgs({ proxy: "http://user:[email protected]:8080" }, {});
    assert.ok(args.length > 0);
    assert.ok(args.every((arg) => !arg.includes("user") && !arg.includes("secret")));
  });

  it("combines http.noProxy and NO_PROXY into http.nonProxyHosts", () => {
    const args = constructSidecarArgs(
      { proxy: "http://proxy.example.com:8080", noProxy: ["registry.example.org"] },
      { NO_PROXY: ".example.internal" },
    );
    assert.strictEqual(
      args[4],
      "-Dhttp.nonProxyHosts=localhost|127.*|[::1]|registry.example.org|*.registry.example.org|*.example.internal",
    );
  });
});

describe("toJavaNonProxyHosts()", () => {
  it("always includes the loopback addresses", () => {
    assert.strictEqual(toJavaNonProxyHosts([]), "localhost|127.*|[::1]");
  });

  it("converts leading dots and adds subdomain wildcards for host names", () => {
    assert.strictEqual(
      toJavaNonProxyHosts([".example.internal", "example.org"]),
      "localhost|127.*|[::1]|*.example.internal|example.org|*.example.org",
    );
  });

  it("keeps IP addresses and existing wildcards as they are", () => {
    assert.strictEqual(
      toJavaNonProxyHosts(["10.1.2.3", "*.example.org"]),
      "localhost|127.*|[::1]|10.1.2.3|*.example.org",
    );
  });

  it("strips ports, skips CIDR ranges and empty entries, removes duplicates", () => {
    assert.strictEqual(
      toJavaNonProxyHosts(["example.org:8443", "10.0.0.0/8", " ", "example.org"]),
      "localhost|127.*|[::1]|example.org|*.example.org",
    );
  });
});

The functions above type-check with tsc --strict and the tests pass in isolation; they have not
been run inside this repository's test setup yet.

Notes
  • Proxy changes take effect on the next sidecar start. This could be documented, or the sidecar
    could be restarted when the http.* settings change.
  • The sidecar is shared with the IntelliJ plugin. Alternatively (or additionally), ide-sidecar could
    read HTTPS_PROXY / HTTP_PROXY / NO_PROXY at startup and set the corresponding system
    properties. That would also help IntelliJ users, but would not pick up VS Code's http.proxy
    setting unless the extension passes it on.
Dominant language
TypeScript
Stars
35
Forks
20
Avg merge
3d 14h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from confluentinc/vscode

All issues in confluentinc/vscode

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.