Repository navigation
Conversation
The kernel backend folded `port` into the host only when `https: false` was set, so `port: 8443` over HTTPS connected to 443 while the Thrift backend honored it. buildKernelHostName folds a supplied non-default port into the host for HTTPS too: - A bare host with a non-default port becomes `host:port`. `port: 443`, an omitted port, and `0` (the Thrift `options.port || 443` default) leave the host unchanged. - A bare IPv6 host gets brackets before the port is appended, on both HTTPS and `https: false` (`[::1]:8443`, `http://[::1]:3015`). With no port the host is unchanged. - A decimal string port such as `'8443'` is accepted, as on Thrift. Non-numeric or out-of-range values throw HiveDriverError. - A port already in `host` is kept, and an explicit `port` must match it. A different one throws HiveDriverError, so a port is never dropped silently. Documented, not guarded: with a non-default port, OAuth on the kernel backend reaches its endpoints at the same `host:port` (Thrift keeps OAuth on the bare host). This is noted in CONNECTION_PARAMETERS.md and CHANGELOG.md. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
…ault
The kernel path folds an explicit `port` into `host`. Review feedback showed
two regressions from the first version of this change, and this commit fixes
them to keep the pre-existing kernel precedence:
- A port embedded in `host` wins over `port`, as on origin/main, where
`{host: 'h:8443', port: 443}` connected to 8443 and
`{host: 'localhost:3015', port: 80, https: false}` connected to 3015.
A differing explicit port is logged as a warning and not thrown. An explicit
443 is treated as the default (getConnectionOptions fills it in) and is not
reported.
- A falsy `port` (0, NaN, '', null, undefined, false) means the default, as on
Thrift (`options.port || 443`). It no longer throws.
- A trailing "/" is dropped before port handling. A path, query or fragment is
rejected only when a port has to be folded into the host, since that would
produce a malformed authority. Inputs with no port are unchanged.
- Truthy invalid ports (non-numeric strings, out of range, true) still throw,
as Thrift also fails on them.
The logger is passed from KernelBackend into buildKernelConnectionOptions.
Tests: table-driven cases in connectionOptions.test.ts cover the precedence,
falsy ports, the warning, and rejection of path and fragment hosts. A Thrift
case in DBSQLClient.test.ts covers falsy-port defaults.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
A host with a path, query or fragment cannot connect on the kernel path, because the kernel puts its API paths after the host. Before this commit, `host: 'h.io/path:8443'` also parsed as host `h.io/path` with embedded port 8443, which passed a broken host straight through. With an explicit `port` (DBSQLClient always supplies 443 by default) such a host now throws HiveDriverError before the embedded-port parse. Without a `port` the host is passed through unchanged, as before. Thrift is unchanged. A test in DBSQLClient.test.ts pins the current Thrift URL for a host with an embedded port (`https://h:8443:443/`), which node-fetch rejects, so the kernel fix does not alter Thrift. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
…e path The path, query and fragment check from the previous commit rejected any explicit port, including the default 443 that DBSQLClient always supplies. That broke inputs that passed through on origin/main: `h/x` with no port or with port 443 over HTTPS was passed to the kernel verbatim before this change. The check now fires only when the port would be folded into the host (`https: false`, or a non-443 port over HTTPS) or when the host carries a port after the path (`h.io/path:8443`), which must not be read as port 8443. With no port, or with 443 over HTTPS and no embedded port, the host passes through unchanged. The check still runs before the embedded-port parse. Tests cover the pass-through cases (no port, port 443, https://host/x) and keep the rejection cases for the folded and embedded-after-path forms. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
The path, query and fragment check now fires only when the explicit port is folded into the host (https: false, or a non-443 port over HTTPS). A host with no folded port passes through unchanged, as on origin/main, including a host with a port after the path (h.io/path:8443), which base passed to the kernel verbatim. The check still runs before the embedded-port parse. Tests keep the rejection cases for the folded form and add pass-through cases for no port, port 443, and an embedded port after a path. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Resolve the CHANGELOG.md conflict by keeping both Unreleased entries: this PR's kernel port entry and main's Arrow row materialization entry. No code conflicts. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 1 low concern. Folding the port into the host keeps the old precedence for embedded ports, and the tests cover the cases well. The one concern is the exemption for port 443 in the warning: its stated reason doesn't hold, because the kernel receives the raw caller options.
Resolve the CHANGELOG.md conflict by keeping both Unreleased entries: this PR's kernel port entry and main's Arrow DECIMAL materialization entry. No code conflicts. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
…bout The comment said getConnectionOptions fills in 443, but backend.connect gets the caller's raw options, so a 443 there was set explicitly. The behavior is intended and unchanged: 443 is the default port, so a host carrying its own port is used without a warning, the same rule as the Python and Go drivers. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
|
@vuanhphung FYI on why this keeps the regex instead of Node's Automated comment from the driver feature factory (Isaac). |
A host with userinfo, such as `user:pw@h` with `port: 8443`, was folded into `[user:pw@h]:8443`: the colon in the userinfo was read as a bare IPv6 literal, so it was bracketed. Userinfo is now set aside before port detection and IPv6 bracketing, and kept in the result as on origin/main, so the same input gives `user:pw@h:8443`. A userinfo host with an embedded port, or with no port, is passed through unchanged as before. The path error and the port-conflict warning echoed the raw host, credentials included. Both now show the host with its userinfo replaced by `***@`. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
lib/kernel/KernelAuth.ts:877— The path/query/fragment check runs before embedded-port detection. As a result, a host likeh.io:7000/xwithport: 8443over HTTPS now throws "port cannot b
Judge's evidence:if (port !== undefined && /[/?#]/.test(authority) && (options.https === false || port !== 443)) {
An empty host with a folded port (https: false, or a non-443 port over HTTPS) reached the kernel as ':<port>'. It now throws HiveDriverError. An empty host with no port, or with 443 over HTTPS, is passed through unchanged, as on origin/main. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Resolve the CHANGELOG.md conflict by keeping both Unreleased entries: this PR's kernel port entry and main's native kernel 1.5.0 upgrade. The unit suite and tsc --noEmit pass on the merged tree. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Looks good: 2 low concerns. The port handling is well covered by table-driven tests, keeps credentials out of errors and warnings, and leaves Thrift unchanged. Nit: the CHANGELOG says a warning is logged on a port conflict, but it doesn't mention that no warning is logged when the explicit port is 443.
redactHost stopped at the first '/', '?' or '#', so a password containing one of them (for example user:p/w@h) was not redacted, and the path error echoed it. It now replaces everything up to the last '@' in the host, as the Go driver does. Tests cover passwords containing '/', '?' and '#'. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
The embedded-port check ran on the whole host text, so a path host with no folded port, such as h.io/x:99999, threw an out-of-range error instead of passing through unchanged as on origin/main. Path hosts that reach that check take no folded port, so they are no longer parsed for one. The port-conflict warning skipped port: 443 even with https: false, where 443 is an explicit, non-default port. The warning now uses the same condition as folding: always with https: false, and only for a non-443 port over HTTPS. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Resolve the CHANGELOG.md conflict after main's 3.1.0 release: this PR's kernel port entry moves to a new Unreleased section above 3.1.0, and main's 3.1.0 list is kept as is. The unit suite and tsc --noEmit pass on the merged tree. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
|
Could this use a single parse instead of the hand-written regexes? Longer term, a This comment was generated with GitHub MCP. |
Summary
On the kernel backend, a custom
portis now honored over HTTPS. Before this PR it was dropped unlesshttps: falsewas set. Thrift is unchanged.Behavior
portis added to a barehostashost:port. A bare IPv6 host gets brackets.port: 443, a falsy port and no port leavehostunchanged.hostwins over a differentport. A warning is logged, except when the explicit port is 443.HiveDriverError. So does ahostwith a path, query or fragment when a port would have to be added to it.host:portfor OAuth, while Thrift uses the bare host. This is documented, not guarded.Testing
Unit tests (1855), type-check, lint and prettier pass.
Related PRs: databricks/databricks-sql-python#1071, databricks/databricks-sql-go#581, https://github.com/databricks/databricks-driver-test/pull/2188
This pull request and its description were written by Isaac.