Skip to content

feat(kernel): honor WithPort on the kernel backend - #581

Merged
cathleeny merged 24 commits into
mainfrom
cathleeny/feat/kernel-honor-custom-port
Dec 1, 2026
Merged

cathleeny merged 24 commits into
mainfrom
cathleeny/feat/kernel-honor-custom-port

Conversation

@cathleeny

@cathleeny cathleeny commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On the kernel backend, WithPort and the DSN port are now honored. Before this PR any value other than 0 or 443 was rejected. Thrift is unchanged.

The kernel applies the port (databricks/databricks-sql-kernel#505). The driver passes WithServerHostname and WithPort to the kernel as is (kernel_session_config_set_port takes an int64), and keeps no port logic of its own.

Behavior

  • Kernel rules:
    • 0 or 443 leaves the host unchanged;
    • any other port is applied as host:port;
    • a non-default port already in the host wins, with a warning. A default port in the host (:443) counts as none.
    • An IPv6 host needs brackets.
    • An out-of-range port, or a host with credentials, a path, query or fragment, is rejected at connect. The error never repeats the host.
  • Errors: a kernel rejection of a non-default port wraps both ErrInvalidKernelConfig and ErrNotSupportedByKernel, so a fallback to the default backend on ErrNotSupportedByKernel still works.
  • Proxy: HTTPS_PROXY / NO_PROXY are evaluated for host:port as on main.

Before merge

  • Bump the databricks-sql-kernel-bindings modules in go.mod / go.sum to a release with kernel_session_config_set_port. The published v1.5.0 archives don't have it, so a databricks_kernel build that links them fails. CI builds the kernel from KERNEL_REV, so it passes.

Testing

  • go test ./... (CGO off), go vet (with and without the kernel tag) and gofmt are clean.
  • The kernel-tagged suite passes against an archive built from the kernel PR. It covers a credentialed host and an out-of-range port, each rejected with both sentinels.
  • Live (dogfood), against main: a custom port is dialed, and a port in the host wins. Bad hosts are rejected before any request, and a 300k-row result is fetched over the custom port. The default, explicit-443, Reyden and Thrift paths match main.

Related PRs: databricks/databricks-sql-kernel#505, databricks/databricks-sql-python#1071, databricks/databricks-sql-nodejs#636, https://github.com/databricks/databricks-driver-test/pull/2188

This pull request and its description were written by Isaac.

The kernel backend rejected any WithPort other than 443. The kernel has no port
setter, but it keeps a `host:port` authority in its host, so the connector now
folds a non-default port into the host it passes to the kernel.

- kernelHostWithPort adds a non-default port with net.JoinHostPort (IPv6-safe).
  The default 443 and an unset port add nothing.
- validateKernelHostPort rejects an out-of-range port, a host with unbalanced IPv6
  brackets (for example `[::1` or `h.databricks.com]`), and a supplied port that
  disagrees with a port embedded in the host. An unset port (WithDefaults fills
  443) defers to the embedded port. An explicit WithPort(443) or DSN port is
  supplied, so it must match an embedded port too (AC-P3: never drop a port).
- UserConfig gains an internal PortExplicit flag, set by WithPort and the DSN
  parser. It is not a public option: internal/ is not importable by users.
- Non-https protocols and the other kernel rejections are unchanged.

With OAuth (M2M and U2M) and a non-default port, the kernel reaches the OAuth
endpoints at the same host:port as the connection. Thrift keeps OAuth on the bare
host. This is documented in CONNECTION_PARAMETERS.md, the README and the
CHANGELOG, and is not guarded.

Tests: one table-driven TestKernelCustomPort covers the host mapping, the
validation (accept and reject, including explicit 443 and unbalanced brackets),
and the kernel Host. The config, connector and driver tests expect PortExplicit
where WithPort or the DSN set the port.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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 Medium

Looks good: one low concern. The port folding, the validation and the PortExplicit plumbing check out, including DeepCopy and the DSN path. Nit: the PortExplicit disposition is listed as "forwarded", but it is only consumed by validation.

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_config.go Resolved
proxyForEndpointFunc appended the port to cfg.Host even when the host already carried one, so host:8443 with Port 8443 built an invalid endpoint, the proxy was dropped and HTTPS_PROXY was ignored. It now uses the same authority as kernelHostWithPort, which leaves an embedded port alone and brackets IPv6 literals.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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 Nit

Looks good, with 1 low concern. The port folding and validation are correct for IPv4, IPv6 and embedded-port cases, and PortExplicit is set by both entry points (WithPort and the DSN parser) and kept by DeepCopy. Nit: the out-of-range error message says "want 1..65535", but port 0 is accepted as unset.

Other findings

  • ⚪ Nit — The Reyden auto-recovery path (openSessionWithReydenFallback → getKernelBackend → buildKernelConfig) now folds a custom port into the kernel Host, where it was rejected before. That is reasonable, but no test or CHANGELOG line covers the recovery path. Add a recovery test with WithPort(8443) that asserts the kernel Host, and mention recovery in the CHANGELOG entry. (Found by Claude Opus 5.5 · confirmed by the judge)

Address the review nits on the kernel custom-port change:

- The out-of-range WithPort error now says 0 is accepted as the default.
- PortExplicit is classified as "validated", not "forwarded": it is consumed
  by validateKernelHostPort and never sent to the kernel.
- A Reyden recovery test with WithPort(8443) asserts that the kernel Host is
  host:8443 after the Thrift KP001 rejection. The CHANGELOG entry mentions the
  recovery path.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
@cathleeny

Copy link
Copy Markdown
Collaborator Author

Fixed the review nits in 263c741:

  • Port range message (review 5980950905): the out-of-range WithPort error now reads "want 1..65535, or 0 for the default", which matches the accepted unset value.
  • Reyden recovery coverage (review 5980950905): TestReydenReactiveRecovery has a new case. A Thrift KP001 rejection with WithPort(8443) recovers onto the kernel, and the case asserts that the kernel Host is reyden.example.com:8443 and that the port passes validation. The CHANGELOG entry now mentions the recovery path.
  • PortExplicit disposition (review 5980504145): the field is now classified as "validated", not "forwarded". This is the same label the experimental classification uses for TLSClientCertConfigured. The flag is consumed by validateKernelHostPort and never sent to the kernel.

CGO_ENABLED=0 go test -count=1 ./... passes for all packages, go vet ./... is clean, and gofmt is clean.

Automated reply from the driver feature factory (Isaac). Not reviewed by a human.

@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).

✅ No issues identified.

Comment thread kernel_config.go Resolved
cathleeny and others added 5 commits November 19, 2026 23:13
…hPort

Fold a trailing "/" in the host before any port handling, matching the
kernel's normalise_host, so WithServerHostname("https://h/") plus
WithPort(8443) connects to h:8443 instead of h/:8443, and
"https://h:8443/" keeps working.

Port precedence now matches the Node and Python kernel paths:
- A port embedded in the host wins over a differing WithPort. The driver
  logs a warning naming both ports and connects to the embedded port.
- A zero (unset) WithPort means the default, with no :443 added.
- A host with a path, query or fragment after the trimmed "/" is
  rejected with ErrInvalidKernelConfig. Base also rejected it: the kernel
  builds {host}/api/2.0/sql, so h/x sent requests to /x/api/2.0/sql.
- Out-of-range WithPort and out-of-range or malformed embedded ports stay
  rejected. Thrift also fails on them: an embedded port plus the default
  443 yields an unparseable https://h:8443:443 URL, -1 is an invalid port,
  and 70000 fails to dial.

Base behavior (origin/main): validateKernelConfigContext rejected any
WithPort other than 0 or 443 with ErrNotSupportedByKernel, and passed the
host through unchanged, so an embedded port connected to that port.

Tests: table cases for h/, h:8443/, h/x, [::1]/, embedded-vs-WithPort
(warn, embedded wins), explicit 443 against an embedded port, and an
invalid port (still rejected). Proxy endpoint test for a trailing-slash
host. Kernel loopback probe: embedded port dialed, explicit port never.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
…xplicit 443

- A host with a path or query is rejected before the embedded-port parse, so
  "h.io/path:8443" with an explicit port cannot slip through. The old code passed
  the host verbatim to the kernel, which builds {host}/api/2.0/sql, so these
  configs never connected.
- The differing-port warning is skipped for an explicit 443 (the default).
- Thrift is unchanged. TestThriftEndpointUnchanged pins its current endpoint
  strings for the same port inputs, including the embedded-port-plus-443 case.

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 is now rejected only when a
  non-default WithPort would have to be folded into it. The check still runs
  after the trailing "/" trim and before the embedded-port parse. With no port
  or 443 the host goes to the kernel unchanged, as on the base branch, where
  the kernel keeps a path prefix ({host}/api/2.0/sql). The base branch rejected
  every non-default WithPort, so nothing that worked before is rejected now.
- Remove the internal PortExplicit field. Once an explicit 443 stopped
  warning, nothing read it, so WithPort, ParseDSN, DeepCopy and their tests
  are back to the base branch.

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 non-finite float rendering entries. No code conflicts.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
The kernel path folds WithPort into cfg.Host. The host is now parsed once per
call with net/url, as the https authority the kernel connects to, instead of
net.SplitHostPort plus hand-written bracket and path scans.

Rules (unchanged unless noted):
- A trailing "/" is trimmed first. With the default port (0 or 443) the host
  passes through unchanged.
- A port embedded in the host wins over a differing WithPort, with a warning.
  An explicit 443, or 0, is the default and is never warned about.
- WithPort outside 1..65535 is rejected. An embedded port that is empty,
  non-numeric or outside 1..65535 is rejected.
- With a non-default port, a host with a path, query, fragment (including an
  empty "h#" or "h?") or user info is rejected. Unbalanced brackets are rejected.
- Errors wrap ErrInvalidKernelConfig as before.

Behavior changes from the reviewed revision (52bd5ac):
- An IPv6 literal must be bracketed. A bare "::1" is rejected at any port
  (net/url cannot parse it). It never connected on main either: the kernel
  prepends https:// and its parse rejects it.
- A host with a password ("user:pw@h") is rejected at any port.
- A host net/url cannot parse (for example "h%zz" or a space) is rejected
  even at the default port, where it used to pass through to the kernel.

The parse-once wrappers and the separate warning helper are gone:
validateKernelHostPort logs the embedded-port warning, and kernelHostWithPort
is the only fold, so buildKernelConfig and resolveKernelProxy keep their
reviewed signatures.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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: 2 Medium · 1 Low

Mostly solid, with 1 medium and 1 low concern. The port folding and validation are well tested, and the Reyden recovery and production paths both go through newKernelBackend's validation. The main problem is that a password in the host can end up in error messages.

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_config.go Resolved
Comment thread kernel_config.go Resolved
Comment thread kernel_config.go Resolved
cathleeny and others added 2 commits November 20, 2026 16:35
…rrors

Bracket a bare IPv6 literal before the kernel host is parsed, so "::1"
and "[::1]" both fold to "[::1]:8443" on every Go version. A DSN IPv6
host reaches the same path, since ParseDSN strips the brackets. ParseDSN
itself is unchanged.

Host-bearing errors now show user info as "<redacted>@h". url.Parse's
text is withheld when the host has user info, because it quotes the
whole URL and a bad escape quotes the password.

A password is still rejected at every port, except that the default
port keeps a host with a path, query or fragment unchanged, as before.
Document that rule in CHANGELOG, README and CONNECTION_PARAMETERS.

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 OAuth M2M token-request timeout entry. No
code conflicts.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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).

✅ No issues identified.

Resolve the CHANGELOG.md conflict by keeping both Unreleased entries: this
PR's kernel port entry and main's leaked-connection fix entry (#177).
kernel_config.go, README.md and CONNECTION_PARAMETERS.md merged without
conflicts. go vet and CGO_ENABLED=0 go test ./... pass on the merged tree.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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).

✅ No issues identified.

cathleeny and others added 2 commits November 23, 2026 18:26
…empty host

Before WithPort was honored, any non-default port on the kernel path
returned ErrNotSupportedByKernel, which doc.go tells callers to check to
fall back to the default backend. The new host/port checks returned only
ErrInvalidKernelConfig, so that fallback stopped firing for the inputs
they reject (a path or credentials with a non-default port, an invalid
port). Each rejection that involves a non-default WithPort now wraps both
errors. A default-port rejection, such as a password in the host, wraps
ErrInvalidKernelConfig only, as before.

An empty host with a non-default port reached the kernel as ":<port>".
It is now rejected. An empty host with the default port is unchanged.

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 kernel v1.5.0 bindings upgrade. go vet and CGO_ENABLED=0 go test ./... pass on the merged tree.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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 Low

Looks good, no blocking issues. Host/port folding, redaction, the ErrNotSupportedByKernel compatibility wrap and proxy endpoint alignment are consistent and well tested. Nit: the Reyden test's fake kernel factory calls validateKernelHostPort and buildKernelConfig by hand, so it doesn't exercise the newKernelBackend wiring itself.

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_config.go Resolved
A password containing '/', '?' or '#' (for example user:p/w@h) ends the authority before the '@', so redactUserinfo found no '@' and returned the raw host, and url.Parse's reason (invalid port ":p") was kept. Both reached the error text with the password in them. Redaction now cuts at the last '@' anywhere in the host, and the parser's reason is withheld whenever an '@' appears. Tests cover passwords containing '/', '?' and '#'; they fail on the previous code.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

@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 Low

Looks good, with one low concern. Host:port folding, IPv6 bracketing and credential redaction are carefully tested. Validation runs on every kernel open path, including the Reyden recovery. Nit: redactUserinfo also redacts a host with no userinfo but an @ in its path or query (h/x@y becomes <redacted>@y).

Comment thread kernel_config.go Resolved
cathleeny and others added 3 commits November 25, 2026 20:37
The driver no longer folds the port into the host. It passes cfg.Host
through unchanged and sets the port with kernel_session_config_set_port
after the host, so the kernel applies the port and validates the
host/port pair. KERNEL_REV moves to b5aac45d54bb4842b7e04dd7fbf2368216b6de4e,
which adds the setter to the C ABI.

The driver keeps the WithPort range check (0..65535, for the uint16
conversion) and the error contract: a kernel InvalidArgument for a
non-default port wraps both ErrInvalidKernelConfig and
ErrNotSupportedByKernel, and the default port wraps only
ErrInvalidKernelConfig. The kernel's messages are already redacted, so
the driver adds no host text.

The proxy endpoint uses a small helper (kernelEndpointHost) that applies
the kernel's simple port rule without validation, so HTTPS_PROXY and
NO_PROXY see the same host:port the kernel dials.

Removed: the driver's host/port validation and folding (path, userinfo,
IPv6 and embedded-port handling, kernelHostWithPort and its helpers).

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Move KERNEL_REV to 22ae6ec250837b38d0e3dc720310d4dcfb81fa98 (databricks/databricks-sql-kernel#505 head) and copy its header. The only header change is the set_port doc comment: a default port never warns about a port already in the host.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>

Co-authored-by: Isaac <no-reply@databricks.com>
Main moved the module path to github.com/databricks/databricks-sql-go/v2.
Resolved the import conflicts in errors_classify.go and its test by keeping
the dbsqlerr import on the /v2 path, and moved the new tagged port_test.go
to /v2 as well. CHANGELOG.md is main's, with the port entry under
Unreleased driver changes. KERNEL_REV keeps 22ae6ec, which already
contains main's 5c3a909, and the header copy still matches it.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@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

Needs changes: 1 high, 1 medium. The kernel-side port handling and tests look right. The new ABI symbol isn't in the pinned published bindings yet, and the host-setter errors now pick up port sentinels.

Comment thread internal/backend/kernel/backend.go Resolved
Comment thread internal/backend/kernel/backend.go Resolved
OpenSession sets the host before the port, so an InvalidArgument from
set_warehouse or set_http_path can't be a port rejection. Tagging those
errors with ErrNotSupportedByKernel for a custom port could trigger a
needless fallback to Thrift. They now keep main's classification.

Also drop the docs' default-port rejection clause: the kernel accepts 443
without validation. And compare the port as int in TestKernelPortPassThrough,
which gosec flagged as a narrowing conversion (G115).

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@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

Looks good: no correctness issues found. set_port runs after the host setter, portRejection returns the documented sentinels, and the proxy endpoint uses the kernel's host:port rule. Merge blocker, already listed in the PR: go.mod still pins bindings v1.5.0, which lacks kernel_session_config_set_port. Bump it along with KERNEL_REV.

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 internal/backend/kernel/backend.go Resolved
cathleeny and others added 3 commits November 30, 2026 18:32
Keep the user-facing change and its requirement; the detailed rules stay
in the connection parameter docs and the PR description.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
The driver no longer validates or folds the port. WithPort and the DSN
port go to the kernel unchanged, and the kernel range-checks the port and
validates the host/port pair at connect. The driver keeps no port logic
of its own.

- kernel.Config.Port is an int, passed to kernel_session_config_set_port
  as int64 when non-zero.
- Drop the driver-side port range check, the uint16 narrowing, and the
  kernelEndpointHost helper. The proxy endpoint is built from Host and
  Port as on main.
- Bump KERNEL_REV to 7e76a603fd4e3ce74e90e6c578e86bc75ac025eb and copy its
  header. The kernel's rules: an IPv6 host needs brackets, a non-default
  port already in the host wins, a default port in the host counts as
  none, and errors never include the host.
- An out-of-range or otherwise invalid non-default port now fails at
  connect, not in config validation. It wraps both ErrInvalidKernelConfig
  and ErrNotSupportedByKernel.
- Update CONNECTION_PARAMETERS.md, README.md and CHANGELOG.md to match.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Resolved the CHANGELOG.md conflict by keeping both Unreleased entries.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@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 · 1 Low

Mostly sound pass-through, with 1 medium and 1 low concern about inputs the driver forwards but the kernel will reject. Merge blocker (already noted in the PR description): go.mod/go.sum still pin bindings v1.5.0, which lacks kernel_session_config_set_port, so default databricks_kernel builds fail to link.

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_config_test.go Resolved
Comment thread kernel_config.go Resolved
Comment thread internal/backend/kernel/backend.go Resolved
cathleeny and others added 2 commits November 30, 2026 22:26
databricks-sql-kernel#505 merged as 3b691d2; pin that commit instead of the
PR head, and copy its C header (it adds kernel main's
kernel_statement_add_parameter_set declaration and comment updates).

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Resolves the KERNEL_REV conflict in favour of 3b691d2 (merged kernel#505),
which already contains main's pin c8113e4 and the SIGPIPE fix.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@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 · 1 Low

Looks good, with 1 low concern. The pass-through and error wrapping are correct and tested. Blocker you already flagged: kernel_session_config_set_port is called for the default port 443 too, so every kernel connection needs bindings with the new symbol. Bump go.mod/go.sum before merge.

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 internal/backend/kernel/backend.go Resolved
Comment thread kernel_config_test.go Resolved
Comment thread kernel_config.go Resolved
proxyForEndpointFunc appended cfg.Port to a host that already had a port,
building an unparsable `h:8443:443` URL, so HTTPS_PROXY and NO_PROXY were
silently skipped. Keep the host's own port, as the kernel does.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@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 · 1 Low

Mostly solid: one medium concern. An IPv6 DSN loses its brackets in ParseDSN, so the kernel rejects it. Merge blocker you already noted: go.mod/go.sum still pin bindings v1.5.0, which lacks kernel_session_config_set_port. Default databricks_kernel builds will fail to link until you bump them.

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 internal/backend/kernel/backend.go Resolved
Comment thread kernel_config.go Resolved
Comment thread README.md
| *(host)* | `WithServerHostname` | Both | *(required)* | Workspace hostname. |
| *(path)* | `WithHTTPPath` | Both | *(required)* | Warehouse/endpoint HTTP path. |
| *(port)* | `WithPort` | Thrift only | `443` | Kernel connects on **443 only** and rejects any other port. |
| *(port)* | `WithPort` | Both | `443` | The port is passed to the kernel as is, and the kernel validates it at connect. `0` leaves the host unchanged, and any other port connects to `host:port`. An IPv6 host needs brackets (`[::1]`, not `::1`), so the port becomes `[::1]:8443`. A non-default port already in the host (`host:8443`) wins over `WithPort` and the kernel logs a warning; a default port in the host (`host:443`) counts as no port, so `WithPort` applies. An invalid port (outside `0..65535`) or host (credentials, a path, query or fragment, an empty host, or an unbracketed IPv6 address) is rejected at connect with `InvalidArgument`. A non-default port's rejection wraps both `ErrInvalidKernelConfig` and `ErrNotSupportedByKernel`. Errors never include the host. With OAuth the kernel uses the same `host:port` for its OAuth endpoints; Thrift keeps OAuth on the bare host. |

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.

At the default port the kernel skips validation: fold_host_port returns as soon as port == default_port, before the @ and path checks. So user:pw@h or h/x with no WithPort still passes, as on main. Could the docs say the rejection applies only with a non-default port? "Errors never include the host" is also too broad. Kernel network errors include the request URL, and Thrift's connect error has host=. Only the port-validation errors leave it out. The CHANGELOG line about both sentinels doesn't hold at 443 either.

if port == kernelDefaultPort {
return fmt.Errorf("%w: %w", err, dbsqlerr.ErrInvalidKernelConfig)
}
return fmt.Errorf("%w: %w: %w", err, dbsqlerr.ErrInvalidKernelConfig, dbsqlerr.ErrNotSupportedByKernel)

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.

The ErrInvalidKernelConfig godoc (errors.go:85-92) defines it "as opposed to unsupported (ErrNotSupportedByKernel)", and says the validation happens in Go before the C ABI. Neither is true after this change. Every port the kernel rejects is a bad config, and Thrift fails on the same input (for example, https://h:70000). So the fallback this wrap enables doesn't help. Could we wrap only ErrInvalidKernelConfig, or else update both sentinels' godoc to say they can occur together?

@cathleeny
cathleeny added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 2a42484 Dec 1, 2026
29 of 36 checks passed
@cathleeny
cathleeny deleted the cathleeny/feat/kernel-honor-custom-port branch December 1, 2026 00:10
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.

2 participants