Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d2e2169
fix(kernel): honor a custom port over HTTPS on the kernel backend
cathleeny Nov 19, 2026
97d67cb
Kernel: embedded host port wins over explicit port; falsy port is def…
cathleeny Nov 19, 2026
a4c91da
Kernel: reject a host path, query or fragment when a port is set
cathleeny Nov 19, 2026
9b2e94d
Kernel: reject a host path only when the port is folded or follows th…
cathleeny Nov 19, 2026
468af3a
Kernel: pass a path host through unless a folded port applies
cathleeny Nov 19, 2026
23ffcf6
Merge main into fix/kernel-honor-https-port
cathleeny Nov 20, 2026
195a115
Merge main into fix/kernel-honor-https-port
cathleeny Nov 20, 2026
2fa5c5e
docs(kernel): correct the reason an explicit port 443 is not warned a…
cathleeny Nov 20, 2026
c8dc980
fix(kernel): keep userinfo out of port detection and messages
cathleeny Nov 23, 2026
f4eef33
fix(kernel): reject an empty host when a port is folded in
cathleeny Nov 23, 2026
110acaf
Merge main into fix/kernel-honor-https-port
cathleeny Nov 23, 2026
fbffc2f
fix(kernel): redact host userinfo up to the last @
cathleeny Nov 23, 2026
69855ec
fix(kernel): leave path hosts unparsed and warn on an HTTP 443 conflict
cathleeny Nov 23, 2026
3be0d05
Merge main into fix/kernel-honor-https-port
cathleeny Nov 23, 2026
2e9227d
refactor(kernel): let the kernel apply the port
cathleeny Nov 25, 2026
1962201
fix(kernel): always send an explicit port to the kernel
cathleeny Nov 25, 2026
09cb0e8
docs(kernel): say any explicit port is sent in KernelPortOptions
cathleeny Nov 25, 2026
bbc4d01
docs(kernel): fix the comment above base.port
cathleeny Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## Unreleased

- Kernel backend: a custom `port` is honored over HTTPS, as on Thrift, and with `https: false`. The kernel applies the port (kernel databricks/databricks-sql-kernel#505): a port other than the scheme default (443 over HTTPS, 80 with `https: false`) is written into `host` as `scheme://host:port`, bare IPv6 hosts are bracketed, and the default or `0` changes nothing. A port already in `host` wins, with a warning when they differ. The kernel rejects credentials, an empty `host`, or a path, query or fragment in `host` when a port is applied. The driver still treats a falsy `port` as the default, accepts a numeric string, and throws `HiveDriverError` for an invalid port. With OAuth and a non-default port, the kernel reaches its OAuth endpoints at the same `host:port`, while Thrift keeps OAuth on the bare host (documented, not guarded). Customer npm installs require a follow-up bump to a published `@databricks/databricks-sql-kernel-*` native package that reads the `port` option; an older published binding does not read it and connects to the default port.

## 3.1.0

- Upgrade to [kernel 1.5.0](https://github.com/databricks/databricks-sql-kernel/releases/tag/v1.5.0): fix CloudFetch pagination, ordering and cancellation, paged inline Arrow results with CloudFetch disabled, and affected-row counts.
Expand Down
18 changes: 9 additions & 9 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ backend (the default), the **SEA / Kernel** backend, or both.

## Connection identity and backend selection

| Option | Type | Thrift | Kernel | Default Value | Note |
| ----------------------- | --------- | :----: | :----: | ------------- | -------------------------------------------------------------------------------------- |
| `host` | `string` | ✅ | ✅ | — (required) | Required on both. |
| `path` | `string` | ✅ | ✅ | — (required) | Kernel also derives `x-databricks-org-id` from a `?o=<id>` query parameter. |
| `port` | `number` | ✅ | ⚠️ | `443` / — | Kernel uses it only with `https: false`; otherwise put a non-default port in `host`. |
| `https` | `boolean` | ✅ | ✅ | `true` | `false` selects plain HTTP; see [Plain HTTP transport](#plain-http-transport). |
| `userAgentEntry` | `string` | ✅ | ✅ | — | Folded into the connector `User-Agent` on both. |
| `useKernel` (internal) | `boolean` | — | — | `false` | Selects the backend: `false`/omitted → Thrift, `true` → Kernel. |
| `clientId` (deprecated) | `string` | ✅ | ✅ | — | Runtime-only alias for `userAgentEntry`. `userAgentEntry` wins when both are supplied. |
| Option | Type | Thrift | Kernel | Default Value | Note |
| ----------------------- | --------- | :----: | :----: | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `host` | `string` | ✅ | ✅ | — (required) | Required on both. |
| `path` | `string` | ✅ | ✅ | — (required) | Kernel also derives `x-databricks-org-id` from a `?o=<id>` query parameter. |
| `port` | `number` | ✅ | ✅ | `443` / — | The kernel applies the port. A port other than the scheme default (443 over HTTPS, 80 with `https: false`) is written into `host` as `scheme://host:port`, with a bare IPv6 host bracketed; the default and `0` change nothing. A port already in `host` wins, with a warning when they differ. The kernel rejects credentials in `host`, an empty `host`, and a path, query or fragment when a port is applied. The driver rejects a non-integer or out-of-range `port` (`HiveDriverError`); a falsy `port` means the default. With OAuth, the kernel uses the same `host:port` for its OAuth endpoints; Thrift keeps OAuth on the bare `host` (port 443). |
| `https` | `boolean` | ✅ | ✅ | `true` | `false` selects plain HTTP; see [Plain HTTP transport](#plain-http-transport). |
| `userAgentEntry` | `string` | ✅ | ✅ | — | Folded into the connector `User-Agent` on both. |
| `useKernel` (internal) | `boolean` | — | — | `false` | Selects the backend: `false`/omitted → Thrift, `true` → Kernel. |
| `clientId` (deprecated) | `string` | ✅ | ✅ | — | Runtime-only alias for `userAgentEntry`. `userAgentEntry` wins when both are supplied. |

Set `client.getConfig().useCloudFetch = false` (default `true`) before opening a session to fetch
complete results without cloud-storage downloads. On the kernel backend this
Expand Down
2 changes: 1 addition & 1 deletion KERNEL_REV
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5c3a909771f749174567af074bfe18c24a335f5c
22ae6ec250837b38d0e3dc720310d4dcfb81fa98
62 changes: 48 additions & 14 deletions lib/kernel/KernelAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,23 @@ export interface KernelFederationOptions {
identityFederationClientId?: string;
}

/**
* Connection port forwarded to the napi binding's `ConnectionOptions.port`.
* The kernel folds it into the host (`fold_host_port`). Any explicit port is
* sent, 443 included; the kernel treats the scheme's default as a no-op (see
* `buildKernelPort`).
*/
export interface KernelPortOptions {
port?: number;
}

export type KernelNativeConnectionOptions = KernelSessionDefaults &
KernelTlsOptions &
KernelHttpOptions &
KernelTelemetryOptions &
KernelProxyOptions &
KernelFederationOptions &
KernelPortOptions &
(
| {
hostName: string;
Expand Down Expand Up @@ -830,20 +841,36 @@ export function buildKernelProxyOptions(options: ConnectionOptions): KernelProxy
return { proxy: out };
}

// The kernel prepends `https://` to a bare host but keeps an explicit scheme.
// It otherwise ignores `port`, so carry it into the URL unless `host` already has one.
function buildKernelHostName(options: ConnectionOptions): string {
if (options.https !== false) {
return options.host;
// An explicit `port` is read as Thrift reads it (`options.port || 443`): a falsy value
// (unset, null, '', 0, NaN, false) means the default. A truthy value must be a whole
// port number, and a decimal string such as `'8443'` is accepted. Anything else throws,
// as Thrift also fails on it.
function explicitPort(port: unknown): number | undefined {
if (!port) return undefined;
let value = Number.NaN;
if (typeof port === 'number') value = port;
else if (typeof port === 'string' && /^[0-9]+$/.test(port)) value = Number(port);
if (value === 0) return undefined;
if (!Number.isInteger(value) || value < 1 || value > 65535) {
throw new HiveDriverError(`kernel backend: \`port\` must be an integer between 1 and 65535; got ${String(port)}.`);
}
// The kernel accepts a full URL in `host`, so drop an existing `http://` or
// `https://` scheme before applying HTTP (`https: false` selects the scheme).
// Then strip a trailing `/` like the Thrift URL builder does.
const host = options.host.replace(/^https?:\/\//i, '').replace(/\/$/, '');
// `name:port` or `[ipv6]:port`; a bare IPv6 literal like `::1` has no port.
const hasPort = /^(\[[^\]]+\]|[^:]+):\d+$/.test(host);
const port = options.port && !hasPort ? `:${options.port}` : '';
return `http://${host}${port}`;
return value;
}

// The host is passed through as given. The kernel owns port folding, IPv6 bracketing,
// userinfo and path checks, and trailing-slash handling, and it prepends `https://` to a
// bare host. The one rewrite left here is plain HTTP: `https: false` sends an explicit
// `http://` scheme, and the kernel's scheme-based default port then applies.
function buildKernelHostName(options: ConnectionOptions): string {
if (options.https !== false) return options.host;
return `http://${options.host.replace(/^https?:\/\//i, '')}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — With https: false and a custom port, the driver no longer folds the port into the host. The @databricks/databricks-sql-kernel-* packages are still pinned to 1.5.0, which ignores port, so those connections now go to port 80. The CHANGELOG admits a follow-up bump is needed. Bump the pins together with this change, or keep folding the port for https: false until the binding ships.

🔀 Found by both reviewers · confirmed by the judge

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The driver no longer folds port into http://host:port for https: false. The npm packages are still pinned to 1.5.0 (package.json lines 95-102), which ignores port. So {host:'localhost', https:false, port:3015} worked before and now connects to port 80 on npm installs. The CHANGELOG admits the gap. Bump the pins in this PR, or keep the fold or add a capability check until the bump lands.

🔀 Found by both reviewers · confirmed by the judge


// The port sent to the kernel, or `undefined` for the default. Any explicit port is sent as
// is: the kernel knows the effective scheme (including an `http://` already in `host`) and
// treats that scheme's default port (443 for https, 80 for http) as a no-op.
function buildKernelPort(options: ConnectionOptions): number | undefined {
return explicitPort(options.port);
}

export function buildKernelConnectionOptions(options: ConnectionOptions): KernelNativeConnectionOptions {
Expand All @@ -858,7 +885,8 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel
} & KernelTlsOptions &
KernelHttpOptions &
KernelProxyOptions &
KernelFederationOptions = {
KernelFederationOptions &
KernelPortOptions = {
hostName: buildKernelHostName(options),
httpPath: prependSlash(options.path),
// Match the NodeJS Thrift driver, which surfaces INTERVAL columns as
Expand All @@ -881,6 +909,12 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel
...buildKernelProxyOptions(options),
};

// Omitted when no port is set; any explicit port, 443 and 80 included, is sent.
const port = buildKernelPort(options);
if (port !== undefined) {
base.port = port;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The driver now drops host-side port folding, but the native packages stay pinned to 1.5.0, which does not read port. npm installs therefore lose the custom https: false port that worked before. The CHANGELOG admits this. Bump the native packages and lockfile in the same release, or keep the fallback folding until then.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The driver now sends port to the native binding and no longer folds it into host, but package.json still pins every platform package to 1.5.0, which does not read port. With the published binding, https: false plus a custom port regresses to port 80. Bump the pins and lockfile to a release containing kernel #505, or keep the old HTTP folding until then. The CHANGELOG already admits this gap.

🔀 Found by both reviewers · confirmed by the judge

}

if (options.enableGeoSpatialSupport !== undefined) {
if (typeof options.enableGeoSpatialSupport !== 'boolean') {
throw new HiveDriverError(
Expand Down
9 changes: 9 additions & 0 deletions native/kernel/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions tests/unit/DBSQLClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,40 @@ describe('DBSQLClient.connect', () => {
expect(connectionOptions.port).to.equal(3015);
});

it('keeps the Thrift URL for a host with an embedded port unchanged (current behavior, not changed by the kernel fix)', async () => {
const client = new DBSQLClient();

// Thrift appends options.port (443 by default) after the host, so an embedded port becomes
// `h:8443:443`, which node-fetch rejects as an invalid URL. This pins that current behavior.
const https = client['getConnectionOptions']({ ...connectOptions, host: 'h.databricks.com:8443', port: 443 });
expect(https.host).to.equal('h.databricks.com:8443');
expect(https.port).to.equal(443);
const httpsConnection = await new HttpConnection(https, client).getThriftConnection();
expect(httpsConnection.url).to.equal('https://h.databricks.com:8443:443/');

const http = client['getConnectionOptions']({
...connectOptions,
host: 'localhost:3015',
port: 80,
https: false,
});
const httpConnection = await new HttpConnection(http, client).getThriftConnection();
expect(httpConnection.url).to.equal('http://localhost:3015:80/');
});

it('treats a falsy port as the default (443 over HTTPS, 80 over HTTP), as the kernel path does', async () => {
const client = new DBSQLClient();

for (const port of [0, Number.NaN, undefined, null, '', false]) {
const label = String(port);
expect(client['getConnectionOptions']({ ...connectOptions, port: port as any }).port, label).to.equal(443);
expect(
client['getConnectionOptions']({ ...connectOptions, port: port as any, https: false }).port,
label,
).to.equal(80);
}
});

it('should only switch to plain HTTP for an explicit https: false', async () => {
const client = new DBSQLClient();

Expand Down
Loading
Loading