Repository navigation
Conversation
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 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.
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
|
Fixed the review nits in 263c741:
Automated reply from the driver feature factory (Isaac). Not reviewed by a human. |
…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 <[email protected]>
Signed-off-by: Cathleen Yan <[email protected]>
…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 <[email protected]>
Signed-off-by: Cathleen Yan <[email protected]>
- 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 <[email protected]>
Signed-off-by: Cathleen Yan <[email protected]>
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 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.
…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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
…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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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, 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.
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 <[email protected]> Signed-off-by: Cathleen Yan <[email protected]>
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 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).
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 <[email protected]> Co-authored-by: Isaac <[email protected]>
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 <[email protected]> Co-authored-by: Isaac <[email protected]>
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 <[email protected]> Co-authored-by: Isaac <[email protected]>
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 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.
| // A rejection here is the WithPort contract's InvalidArgument (see portRejection). | ||
| if k.cfg.Port != 0 { | ||
| if err := call(func() C.KernelStatusCode { | ||
| return C.kernel_session_config_set_port(cfg, C.uint16_t(k.cfg.Port)) |
There was a problem hiding this comment.
🟠 High — The new cgo call to kernel_session_config_set_port needs an archive exporting that symbol, but go.mod still pins every kernel-bindings module at v1.5.0 and only KERNEL_REV and the header changed. A databricks_kernel build that links the published modules will fail with an undefined symbol. Publish bindings that include set_port and bump go.mod and go.sum in this change.
🔀 Found by both reviewers · confirmed by the judge
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 <[email protected]> Co-authored-by: Isaac <[email protected]>
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 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.
| // A rejection here is the WithPort contract's InvalidArgument (see portRejection). | ||
| if k.cfg.Port != 0 { | ||
| if err := call(func() C.KernelStatusCode { | ||
| return C.kernel_session_config_set_port(cfg, C.uint16_t(k.cfg.Port)) |
There was a problem hiding this comment.
🟠 High — The new cgo call to kernel_session_config_set_port needs a kernel library that exports it, but go.mod still pins every platform binding at v1.5.0. KERNEL_REV was bumped, and a link failure for tagged databricks_kernel builds is plausible. I couldn't check the published archives. Bump the bindings in go.mod/go.sum to a release that exports the symbol, and verify a tagged build against the published archives before merging.
🔀 Found by GPT-6.1 Sol · confirmed by the judge
Summary
On the kernel backend,
WithPortand the DSNportare now honored. Before this PR any value other than 0 or 443 was rejected. Thrift is unchanged.The kernel now applies the port (databricks/databricks-sql-kernel#505). The driver passes
WithServerHostnamethrough unchanged and sets the port withkernel_session_config_set_port, so Go no longer parses or folds the host itself.Behavior
host:port, with a bare IPv6 host bracketed;WithPortrange (0..65535) and keeps the error contract. A kernel rejection of a non-default port (fromset_port) wraps bothErrInvalidKernelConfigandErrNotSupportedByKernel, so a fallback to the default backend onErrNotSupportedByKernelstill works. Host setter errors keep main's classification.HTTPS_PROXY/NO_PROXYare evaluated against the samehost:portthe kernel dials, using a small helper with no validation.host:portfor OAuth. This is documented.Before merge
KERNEL_REVpoints at the kernel PR's head (22ae6ec), andinternal/backend/kernel/include/databricks_kernel.his copied from it. Move it to the merged kernel commit.databricks-sql-kernel-bindingsmodules ingo.mod/go.sumto a release that exportskernel_session_config_set_port. The published v1.5.0 archives don't, so adatabricks_kernelbuild that links them fails with an undefined symbol. CI's kernel job builds the kernel fromKERNEL_REV, so it passes.Testing
go test ./...with CGO off,go vetand gofmt are clean.WithPort(443), a host with:443, and Thrift on 443 pass.Related PRs: https://github.com/databricks/databricks-sql-kernel/pull/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.