Skip to content

feat: add https connection option to allow plain HTTP transport - #588

Open
vuanhphung wants to merge 4 commits into
mainfrom
feat/issue-503-http-transport
Open

vuanhphung wants to merge 4 commits into
mainfrom
feat/issue-503-http-transport

Conversation

@vuanhphung

Copy link
Copy Markdown
Collaborator

DBSQLClient.getConnectionOptions() hardcoded https: true, so apps that reach Databricks through a trusted local reverse proxy (app --HTTP--> proxy --HTTPS--> Databricks) had to monkey-patch that private method, even though HttpConnection already supports plain HTTP.

This adds a public opt-in, https?: boolean, to ConnectionOptions. It matches the internal IConnectionOptions.https it maps to. HTTPS stays the default, and only an explicit false turns it off. With https: false the default port is 80, and clientCert/clientKey are rejected instead of being silently dropped (the kernel rejects that combination too). The kernel binding keeps an explicit http:// host, so the kernel backend gets http://host[:port]. That also keeps Thrift's Reyden fallback to the kernel on the same transport. On Thrift the scope is deliberately limited to the SQL connection: OAuth, token federation, telemetry and feature-flag requests still use HTTPS. CloudFetch presigned URLs are untouched. CONNECTION_PARAMETERS.md documents this and warns that plain HTTP is only for trusted local or private links.

Verification: new unit tests cover the option mapping and run a real open/close round trip against a local plain-HTTP Thrift server. Without the fix, that round trip fails with a TLS wrong version number error. A new e2e spec runs SELECT 1 on a live warehouse over https: false through a local reverse proxy on both backends. The existing proxy e2e test now uses the public option instead of overriding the private method. On the default path, a live 200k-row query on both backends confirmed Thrift still uses an https.Agent on port 443 and the kernel host is passed through unchanged. npm test (1537 passing), lint, type-check and build pass. Performance isn't affected: the change runs once per connect() while building options, and no per-request or per-row code changed.

Fixes #503

This pull request and its description were written by Isaac.

DBSQLClient hardcoded `https: true`, so callers behind a trusted local
reverse proxy had to monkey-patch the private getConnectionOptions().
`https: false` now selects plain HTTP (port 80 by default) on the Thrift
transport, and the kernel backend receives an explicit http://host[:port]
host. HTTPS stays the default; mTLS client identity is rejected over HTTP.

Fixes #503

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@peco-review-bot peco-review-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.

Verdict: 1 Low

Looks good overall, with one low-severity edge case. On the kernel path with https: false, setting a port both in host and in port produces a doubled port in the URL. The mapping is correct otherwise: Thrift defaults, the kernel http:// host and rejecting mTLS over plain HTTP all work, and mTLS is rejected on both backends because the kernel path also calls createConnectionProvider.

Comment thread lib/kernel/KernelAuth.ts Resolved
With `https: false`, the kernel host name appended `port` even when `host`
already carried a `:port` suffix (the kernel's documented convention),
producing an invalid `http://localhost:3015:3015`.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@peco-review-bot peco-review-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.

Verdict: 1 Low

Looks good, with one low-severity edge case in how the kernel builds the host URL for bare IPv6 hosts. The option mapping, the mTLS rejection, the docs and the tests (including a real plain-HTTP Thrift round trip) match the intended behaviour. The Thrift-only mTLS check is fine because the kernel enforces it itself.

Comment thread lib/kernel/KernelAuth.ts Resolved
`/:\d+$/` matched literals like `::1`, so the kernel dropped `port`. Only
`name:port` and `[ipv6]:port` now count as an embedded port, giving the
same URL shape as the Thrift transport.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@peco-review-bot peco-review-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.

Verdict: 1 Low

Looks good: one low-severity concern about a trailing slash in the kernel http:// host. The https option maps cleanly onto HttpConnection's existing plain-HTTP support. The defaults stay HTTPS-only, mTLS is rejected up front, and both backends have unit and e2e coverage.

Comment thread lib/kernel/KernelAuth.ts Resolved
Thrift strips a trailing `/` from `host` before adding the port; the
kernel mapping did not, producing `http://localhost/:3015`.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@peco-review-bot peco-review-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.

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — 6e5c6553 Deployed Nov 11, 2026 by vuanhphung via e2e-test (22.23.4, 22_23_4) #1889
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.

Allow selecting HTTP transport in DBSQLClient.connect()

1 participant