Skip to content

feat(kernel): support SOCKS proxies from HTTPS_PROXY on the kernel backend - #607

Merged
cathleeny merged 1 commit into
mainfrom
cathleeny/ddf-socks-proxy-go
Dec 3, 2026
Merged

cathleeny merged 1 commit into
mainfrom
cathleeny/ddf-socks-proxy-go

Conversation

@cathleeny

@cathleeny cathleeny commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Makes SOCKS proxies from the environment behave on the kernel backend as they do on the Thrift backend, using the kernel's SOCKS support (databricks/databricks-sql-kernel#518).

  • An HTTP(S)_PROXY socks5:// URL is passed to the kernel as socks5h://, because net/http lets the proxy resolve socks5:// host names. When the warehouse would use a socks4:// or socks4a:// proxy, the connection fails with ErrInvalidKernelConfig, as net/http can't use them either; the error names the scheme, never the URL. When NO_PROXY bypasses the warehouse, such a proxy is passed to the kernel, which uses it (never a direct connection) for any other host that selects it.
  • The environment proxy applies to every kernel destination (warehouse, CloudFetch storage and OAuth). NO_PROXY is translated into the kernel's bypass list, also when it bypasses the warehouse. The warehouse always follows http.ProxyFromEnvironment exactly. For other hosts the kernel matches host names only, so host:port entries apply only with port 443, and .example.com also bypasses example.com. CONNECTION_PARAMETERS.md documents both; exact per-host routing needs a kernel API change and is a separate follow-up. The environment is read once per process, as on the Thrift path.
  • WithKernelProxy URLs, credentials and bypass lists still pass through unchanged; its docs now mention SOCKS URLs.
  • With only ALL_PROXY set, the driver passes no proxy and the kernel reads the environment itself (Thrift ignores ALL_PROXY). This is documented.

No options are added or renamed, and defaults are unchanged.

Dependencies

  • KERNEL_REV pins the merged kernel commit a29235c (feat(client): support SOCKS4/4a/5/5h proxies databricks-sql-kernel#518), so make test-kernel builds a SOCKS-capable kernel from source.
  • The tracked internal/backend/kernel/include/databricks_kernel.h is synced to that commit, as on every pin bump. Besides the SOCKS proxy docs, it picks up the kernel's certificate-revocation setter, which this driver doesn't call.
  • The published kernel bindings in go.mod (v1.5.0, which rejects SOCKS URLs) move with the next kernel release.

Validation

  • Unit tests (CGO_ENABLED=0):
    • TestProxyForEndpoint and TestKernelBypassHosts cover socks5 → socks5h and socks4/4a rejection.
    • They also cover storage and OAuth bypass entries, a bypassed warehouse, port and leading-dot entries, *, and IP/CIDR entries.
    • TestResolveKernelProxyEnvironment runs each case in a child process with a real environment, including ALL_PROXY alone and WithKernelProxy winning over the environment.
  • Checks: go vet, go test -race, the -tags databricks_kernel tests and make test-kernel (built from KERNEL_REV) pass, and lint reports no new findings.
  • Live against staging DBSQL and Reyden warehouses with kernel a29235c, through a loopback SOCKS fixture that records each handshake, with same-session Thrift rows:
    • Env socks5h/socks5 send the domain to the proxy, as on Thrift.
    • Env socks4/socks4a with the warehouse proxied fail closed with ErrInvalidKernelConfig; with NO_PROXY bypassing the warehouse, the connection works directly.
    • Credentials are accepted, or rejected after one attempt, and a dead proxy fails closed.
    • NO_PROXY host and suffix entries go direct, ALL_PROXY alone works, and WithKernelProxy wins over the environment.
    • A 200,000-row CloudFetch query downloads through the proxy; with the storage host in NO_PROXY, storage goes direct while the warehouse is proxied.
    • An HTTP CONNECT proxy still works.
    • SELECT 1 through socks5h: within max(+25 %, +150 ms) of direct in 4 of 6 runs across the two warehouses. The other two missed by under 20 ms while the warehouses' direct medians ranged from 580 to 3076 ms.

This pull request and its description were written by Isaac.

@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from c0692fb to 4b8bb28 Compare December 1, 2026 19:41
@cathleeny
cathleeny marked this pull request as ready for review December 1, 2026 19:42
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from 4b8bb28 to d00ce35 Compare December 1, 2026 20:25

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Mostly solid: 1 medium, 1 low. The env rewrite and rejection logic are correct and well tested. The main concern is that the docs claim SOCKS support while the pinned kernel bindings may not ship it yet.

Comment thread CHANGELOG.md Resolved
Comment thread kernel_proxy.go Resolved
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from d00ce35 to 87d2133 Compare December 1, 2026 21:10

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High

Needs a kernel pin before merging: 1 high concern. The driver-side env mapping (socks5→socks5h, failing closed on socks4/4a, keeping credentials out of errors) is correct and well tested. The SOCKS support it documents depends on a kernel release this PR doesn't pin.

Comment thread CHANGELOG.md Resolved

@aakash-saravanan-db aakash-saravanan-db 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.

Thanks for the PR! Normalizing environment socks5 to socks5h preserves Go's proxy-side DNS behavior, and the scheme-only error keeps credentials out of diagnostics. The isolated environment tests are useful for avoiding the standard library's cached environment state.

The main change needed is to preserve that policy for every request destination, including CloudFetch storage and OAuth hosts. I've also left a small test-necessity comment and followed up on the existing source-pin discussion; the published bindings update remains separate release work.

Please also shorten the PR description to the public behavior, dependencies, and relevant validation, removing internal tracking details and prior-review history.


This review was generated with GitHub MCP.

Comment thread kernel_config.go Resolved
Comment thread internal/backend/kernel/kernel_test.go Resolved
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from 87d2133 to 46e6e6b Compare December 2, 2026 01:18

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with 1 low concern. The SOCKS rewrite and rejection, the NO_PROXY translation and the warehouse parity with Go are correct and well tested, including real-environment tests in a child process. The CHANGELOG entry understates how far the NO_PROXY handling changed.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • 🟠 High — The rewritten SOCKS URL still reaches the native setter, but the pinned kernel rejects SOCKS as acknowledged in the PR description, leaving the advertised feature unusable with the default dependency configuration. Update both the released bindings and source-build pin before merging, and add a tagged SOCKS setter test against those dependencies. (Found by GPT-6.1 Sol · the judge couldn't confirm it)

Comment thread CHANGELOG.md Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

The proxy translation logic looks correct, with one medium concern: the changelog announces SOCKS support before the linked kernel can use it. The kernel.Config proxy doc in internal/backend/kernel/config.go (outside the diff) still says the env path leaves ProxyBypassHosts empty, which this PR makes untrue (nit).

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread kernel_proxy.go Resolved
Comment thread kernel_proxy.go Resolved
@cathleeny

Copy link
Copy Markdown
Collaborator Author

On the review's other finding (High, kernel pin), which the bot's judge couldn't confirm: not changing this here. It's the merge prerequisite already discussed in the resolved KERNEL_REV thread and listed under Dependencies. KERNEL_REV and the bindings move once databricks/databricks-sql-kernel#518 merges and is released, and a SOCKS setter test against those dependencies isn't possible before then.

@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from fd2ead6 to 2747d8d Compare December 2, 2026 02:30

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with 1 low concern. The NO_PROXY translation matches httpproxy's rules, the SOCKS scheme mapping fails closed without leaking the URL, and tests cover the branches. Nits: the WithKernelProxy doc still says "basic-auth credentials" only, and the env fallback assertion in TestResolveKernelProxy is now weak (exact cases live in the child-process test).

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • 🟠 High — The new SOCKS translation still reaches a kernel that rejects SOCKS URLs: the shipped bindings remain v1.5.0 and KERNEL_REV remains 3b691d2, as acknowledged in the description, so the advertised feature cannot work for consumers of this PR. Update the published bindings pins and KERNEL_REV before merging, and add a SOCKS case to the real applyProxy setter test so this dependency gap fails validation. (Found by GPT-6.1 Sol · the judge couldn't confirm it)

Comment thread kernel_proxy.go Resolved
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from 2747d8d to 311641d Compare December 2, 2026 08:43

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with 1 low concern. I checked the SOCKS rewrite, the NO_PROXY translation and the error propagation from resolveKernelProxy, and they look correct and well tested. The Reyden fallback path doesn't call resolveKernelProxy, but that was already true before this PR.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • 🟠 High — The new SOCKS URL still reaches a native proxy setter without the required kernel dependency update: the PR acknowledges that pinned revision 3b691d2 rejects SOCKS, and the published bindings remain unchanged, so normal pinned builds cannot deliver this feature. Update KERNEL_REV and the released bindings together before merging, and add a tagged SOCKS case exercising the real applyProxy setter. (Found by GPT-6.1 Sol · the judge couldn't confirm it)

Comment thread kernel_proxy.go Resolved
@cathleeny

Copy link
Copy Markdown
Collaborator Author

On the latest review's High (pinned kernel and bindings), which the bot's judge couldn't confirm: it's the merge prerequisite already answered in the resolved KERNEL_REV threads and listed under Dependencies. KERNEL_REV and the bindings move together once databricks/databricks-sql-kernel#518 merges and is released. A tagged SOCKS case against the real setter would only pass after that pin bump, so it belongs in that change.

@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from 311641d to b851e2e Compare December 2, 2026 09:12

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High

Mostly solid, with 1 medium concern: the docs claim SOCKS support that the pinned kernel bindings don't provide yet. The NO_PROXY translation and the warehouse-exact filtering look correct and are well tested. Nit: the WithKernelProxy doc comment still says "basic-auth credentials", while the struct docs now also cover RFC 1929 for SOCKS5.

Comment thread CHANGELOG.md Resolved

@aakash-saravanan-db aakash-saravanan-db 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.

Thanks for fixing the bypassed-warehouse SOCKS4 case. Approving with the documented per-destination routing limitations accepted for follow-up. I've left the remaining routing details in the existing thread and one non-blocking documentation comment.


This review was generated with GitHub MCP.

Comment thread connector.go Resolved
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from b851e2e to e874f13 Compare December 2, 2026 22:10

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with 1 low concern. The proxy and bypass translation, the SOCKS5-to-socks5h rewrite, and the fail-closed SOCKS4 check are well covered by unit tests and child-process environment tests. Exact per-host bypass parity with Go needs a kernel API change, so it remains follow-up work.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • 🟠 High — The new SOCKS URLs still reach a native setter that rejects them in the pinned kernel, so consumers of this PR cannot use the advertised feature despite the pure-Go tests passing. Land the SOCKS-capable published bindings and matching kernel pin before merging, and add a tagged test through trySetProxy that verifies SOCKS acceptance against the shipped archive. (Found by GPT-6.1 Sol · the judge couldn't confirm it)

Comment thread CONNECTION_PARAMETERS.md Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Medium

The proxy code itself looks sound, but there are 2 medium concerns about the kernel pin and what this PR ships. go.mod still links bindings v1.5.0, and the KERNEL_REV/header bump goes against the PR description.

Comment thread KERNEL_REV Resolved
Comment thread kernel_proxy.go Resolved
…ckend

With a kernel that supports SOCKS, keep the Thrift path's behavior for an
environment-derived SOCKS proxy on the kernel path. net/http resolves
socks5:// targets at the proxy, so an HTTPS_PROXY socks5:// URL is sent to
the kernel as socks5h://. net/http cannot use socks4/socks4a, so when the
warehouse selects one the connection fails with ErrInvalidKernelConfig; the
error names the scheme, not the URL. When NO_PROXY bypasses the warehouse,
a socks4/socks4a URL is passed as is, since no request may need it.
WithKernelProxy URLs are still passed verbatim with kernel semantics.

The environment proxy now applies to every kernel destination: the driver
passes it with NO_PROXY translated into the kernel's bypass list, so
CloudFetch storage and OAuth hosts in NO_PROXY connect directly. When
NO_PROXY bypasses the warehouse, the proxy is still passed with the
warehouse added to the bypass list, instead of leaving the kernel to read
the raw environment. The warehouse always follows Go's NO_PROXY rules, and
the environment is read once per process, as on the Thrift path.

Document the kernel-path SOCKS and NO_PROXY behavior, including ALL_PROXY,
which the kernel reads itself when no HTTP(S)_PROXY applies.

Bump KERNEL_REV to a29235c, the merged kernel SOCKS change
(databricks/databricks-sql-kernel#518), and sync
internal/backend/kernel/include/databricks_kernel.h with that commit's
header.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@cathleeny
cathleeny force-pushed the cathleeny/ddf-socks-proxy-go branch from 38a3545 to ba98d6e Compare December 2, 2026 23:11

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High

Mostly solid, with 1 medium concern: the docs and CHANGELOG say SOCKS works before the published kernel bindings ship it. The NO_PROXY translation and the socks5 → socks5h / socks4 rejection logic look correct and are well tested.

Comment thread kernel_proxy.go Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants