From cf1e9e00cfd5a2e9213a75150cffb268c116fab7 Mon Sep 17 00:00:00 2001 From: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Date: Thu, 3 Dec 2026 20:08:47 +0000 Subject: [PATCH] fix(kernel): point WithTransport rejection to the WithKernel* options On the kernel backend a custom WithTransport is rejected with ErrNotSupportedByKernel. The fix-it text said "use the default (Thrift) backend", which is wrong after Reyden auto-recovery: Reyden warehouses reject Thrift (KP001). The message now points to the WithKernel* TLS and proxy options and qualifies the Thrift suggestion to warehouses that accept Thrift. Add hermetic tests for both recovery paths (KP001 recovery and the cached Reyden pre-check) that assert the sentinels, the message, and that the caller's transport is never called. Document the Reyden limitation in CONNECTION_PARAMETERS.md. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com> Co-authored-by: Isaac --- CHANGELOG.md | 1 + CONNECTION_PARAMETERS.md | 5 ++-- connector_reyden_test.go | 54 ++++++++++++++++++++++++++++++++++++++++ kernel_config.go | 3 ++- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d6136a..6dad9d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Driver changes +- Clarify the kernel error for `WithTransport` with guidance for TLS and proxy configuration. - Lower the minimum supported Go version from 1.27.3 to 1.26.11. Go 1.27 users need 1.27.4 or newer for the emSign certificate distrust and November security fixes. The `go.mod` minimum accepts every Go 1.27 patch, including 1.27.0 through 1.27.3. - Read buffered kernel result batches without a runtime hop, falling back to a blocking fetch when needed. - Honor `WithPort` and the DSN port on the kernel backend, including after automatic Reyden recovery, instead of rejecting a non-default port. IPv6 hosts need brackets, and a port the kernel rejects returns an error wrapping both `ErrInvalidKernelConfig` and `ErrNotSupportedByKernel`. diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 8b31a592..453280e8 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -201,8 +201,9 @@ chunks, not bytes, and do not include consumer or application buffers. | `WithKernelSkipHostnameVerify()` | ❌ | ✅ | Skip **only** the hostname check while keeping chain validation (finer-grained than `WithSkipTLSHostVerify`). Rejected on Thrift. | The `WithTransport` rejection is deliberate — a Go transport can't cross the C ABI into the -kernel's Rust HTTP stack. The dedicated kernel TLS knobs cover what a custom transport is -used for: +kernel's Rust HTTP stack. `WithTransport` cannot be used with Reyden warehouses, which require the +kernel; use the `WithKernel*` TLS and proxy options instead. The dedicated kernel TLS knobs cover +what a custom transport is used for: | Reason for a custom `WithTransport` | Kernel option | |---|---| diff --git a/connector_reyden_test.go b/connector_reyden_test.go index 151dcb26..eaa90abd 100644 --- a/connector_reyden_test.go +++ b/connector_reyden_test.go @@ -328,6 +328,60 @@ func TestReydenPreCheck(t *testing.T) { }) } +// reydenCountingTransport verifies that kernel construction does not invoke the caller's transport. +type reydenCountingTransport struct{ calls int } + +func (rt *reydenCountingTransport) RoundTrip(*http.Request) (*http.Response, error) { + rt.calls++ + return nil, errors.New("unexpected transport request") +} + +func TestReydenWithTransportRejection(t *testing.T) { + for _, cached := range []bool{false, true} { + name := "KP001 recovery" + if cached { + name = "cached Reyden pre-check" + } + t.Run(name, func(t *testing.T) { + defer warehouse_cache.ClearCache() + tt := NewTestReydenFallback() + if cached { + warehouse_cache.MarkReyden(tt.host, tt.warehouseID) + } + thriftCalled, kernelCalled := false, false + kernelBackend := &fakeKernelBackend{} + conn := tt.makeConnector( + func(ctx context.Context, cfg *config.Config, client *http.Client) (backend.Backend, error) { + thriftCalled = true + return &fakeThriftBackend{openSessionErr: dbsqlerrint.NewReydenThriftUnsupportedError( + "Lakehouse/RT is not supported for Thrift protocol")}, nil + }, + func(ctx context.Context, cfg *config.Config) (backend.Backend, error) { + kernelCalled = true + if _, err := validateKernelConfigContext(ctx, cfg); err != nil { + return nil, err + } + return kernelBackend, nil + }, + ) + transport := &reydenCountingTransport{} + WithTransport(transport)(conn.cfg) + be, _, err := conn.openSessionWithReydenFallback(context.Background()) + require.Error(t, err) + assert.ErrorIs(t, err, dbsqlerr.ErrNotSupportedByKernel) + assert.Equal(t, !cached, errors.Is(err, dbsqlerr.ErrReydenThriftUnsupported)) + assert.Contains(t, err.Error(), "WithTransport") + assert.Contains(t, err.Error(), "WithKernel* TLS and proxy options") + assert.Contains(t, err.Error(), "warehouses that accept Thrift") + assert.Equal(t, !cached, thriftCalled) + assert.True(t, kernelCalled) + assert.Nil(t, be) + assert.False(t, kernelBackend.SessionValid()) + assert.Zero(t, transport.calls) + }) + } +} + func TestReydenCacheMarking(t *testing.T) { t.Run("Rejection marks warehouse in cache", func(t *testing.T) { defer warehouse_cache.ClearCache() diff --git a/kernel_config.go b/kernel_config.go index 2e2b08d7..0970ed52 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -86,7 +86,8 @@ func validateKernelConfigContext(ctx context.Context, cfg *config.Config) (kerne // a wholesale custom Transport is unsupported.) if cfg.Transport != nil { return kernel.Auth{}, fmt.Errorf("databricks: a custom WithTransport (RoundTripper) is %w "+ - "(the kernel uses its own HTTP stack); use the default (Thrift) backend", dbsqlerr.ErrNotSupportedByKernel) + "(the kernel uses its own HTTP stack); use WithKernel* TLS and proxy options, "+ + "or use the Thrift backend for warehouses that accept Thrift", dbsqlerr.ErrNotSupportedByKernel) } // Auth: resolve the kernel auth form (PAT / OAuth M2M / U2M) off cfg.Authenticator, // the single source of truth. resolveKernelAuth rejects unsupported authenticators