Skip to content

[SEA-NodeJS] Kernel-parity batch: mTLS + custom headers/UA + retry/backoff + operation-status fields#420

Open
msrathore-db wants to merge 8 commits into
mainfrom
msrathore/sea-mtls-headers-useragent
Open

[SEA-NodeJS] Kernel-parity batch: mTLS + custom headers/UA + retry/backoff + operation-status fields#420
msrathore-db wants to merge 8 commits into
mainfrom
msrathore/sea-mtls-headers-useragent

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

@msrathore-db msrathore-db commented Jun 5, 2026

What

Consolidated PR landing every kernel-supported capability that was missing on the Node SEA path — the items the kernel core (and the Python connector) already support but the Node driver did not yet wire. Folds in the previously-separate #427 and #422.

Features

  1. mTLS + custom HTTP headers + user-agent entry (orig. this PR) — clientCertPem/clientKeyPem, customHeaders, userAgentEntry → kernel TlsConfig / HttpConfig.custom_headers. Kernel: ✅ · Python: ✅ #819/#823.
  2. Retry/backoff tuning (was [SEA-NodeJS] Forward retry/backoff tuning to the kernel on the SEA path #427) — buildSeaRetryOptions maps the driver's ClientConfig retry knobs (ms) → kernel retry{Min,Max}WaitSecs / retryMaxAttempts / retryOverallTimeoutSecs (whole secs), merged in SeaBackend.connect(). Unset knobs are omitted (kernel default stands; no NaN across the FFI). Kernel: ✅ (napi kwargs added in kernel Patch-Package security vulnerability #141) · Python: ✅ #820.
  3. Operation-status fields (was [SEA-NodeJS] Surface operation-status fields (displayMessage/diagnosticInfo/errorDetailsJson, numModifiedRows) on getOperationStatus #422) — numModifiedRows / displayMessage / diagnosticInfo / errorDetailsJson surfaced through getOperationStatus instead of a flat Succeeded (the M1 item in SeaOperationLifecycle). Kernel: ✅ · Python: ✅ #825.

Plus the napi package-name alignment to @databricks/databricks-sql-kernel-* (kernel #131/#135).

Verification

  • Full SEA unit suite: 280 passing, tsc clean.
  • KERNEL_REV regenerated against the unified kernel SHA carrying mTLS + retry.

⚠️ Depends on kernel #141

KERNEL_REV is pinned to #141's branch HEAD (fcc459b) as a placeholder — it carries the napi retry kwargs. Re-pin to #141's squash-merge SHA before merge (orphan-SHA risk otherwise). Kernel #141 is armed for auto-merge.

Supersedes

This pull request and its description were written by Isaac.

@msrathore-db msrathore-db force-pushed the msrathore/sea-mtls-headers-useragent branch from 68dbb3d to 1607ce0 Compare June 5, 2026 01:11
@msrathore-db msrathore-db force-pushed the msrathore/sea-mtls-headers-useragent branch from 1607ce0 to b0cf092 Compare June 5, 2026 01:31
@msrathore-db msrathore-db force-pushed the msrathore/sea-mtls-headers-useragent branch from b0cf092 to cdcf766 Compare June 5, 2026 01:40
@msrathore-db msrathore-db force-pushed the msrathore/sea-mtls-headers-useragent branch from cdcf766 to 84924c9 Compare June 5, 2026 01:56
Wire the SEA/kernel path's remaining TLS-adjacent connection options
through to the napi binding, matching the Python connector's use_kernel
path (session.py + backend/kernel/client.py):

- mTLS client identity: `clientCertPem` / `clientKeyPem` (PEM string or
  Buffer), normalised to Buffers and routed to the kernel
  `TlsConfig::client_cert_pem` / `client_key_pem`. Both-or-neither
  enforced up front with an actionable error.
- Independent hostname-verify toggle: `checkServerCertificateHostname`
  (kernel `skip_hostname_verification`) for full parity with Python's
  `tls_verify_hostname` — skip only the hostname check while still
  validating the chain. The master `checkServerCertificate=false` still
  subsumes it.
- Custom HTTP headers + User-Agent: headers cross the FFI as an ordered
  list (`Array<{name,value}>`, the napi `HeaderEntry` shape matching the
  kernel core `Vec<(String,String)>` and Python's `List[Tuple]`): caller
  `customHeaders` first, then the connector's composed `User-Agent`
  appended last (always emitted; the kernel folds the last User-Agent into
  its base `DatabricksJDBCDriverOSS/...` UA). Kernel-managed reserved names
  `Authorization` / `x-databricks-org-id` are dropped before the FFI hop,
  matching Python's `_KERNEL_MANAGED_HEADERS` double-wall.

Adds `buildSeaHttpOptions`, extends `buildSeaTlsOptions`/`SeaTlsOptions`,
and factors PEM normalisation into a shared helper. Bumps KERNEL_REV and
regenerates `native/sea/index.d.ts`. Unit tests cover mTLS
pairing/validation, the hostname toggle, ordered header pass-through,
reserved-name dropping, and User-Agent composition/ordering; verified the
real native binding marshals every new field across the FFI and rejects a
wrong header shape.

Depends on the kernel napi change exposing clientCertPem / clientKeyPem /
customHeaders / checkServerCertificateHostname; KERNEL_REV must be
repointed to that commit once merged.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
@msrathore-db msrathore-db force-pushed the msrathore/sea-mtls-headers-useragent branch from 84924c9 to cfe3b3f Compare June 5, 2026 08:41
Kernel #126 (logging bridge) and #127 (mTLS identity + custom HTTP headers)
are both merged to kernel main. Pin KERNEL_REV to the unified main SHA
80b68e1eef3b613910183a50dfa4dace854d50dd and regenerate native/sea/index.*
from it. The contract now carries both feature surfaces (gains the logging exports from #126).

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Same alignment as the logging PR: kernel #131/#135 renamed the published napi
package @databricks/sql-kernel -> @databricks/databricks-sql-kernel. Update the
packaging test, version-test hint, SeaNativeLoader install hint, and README to
match the regenerated router, fixing the native-packaging unit tests under the
KERNEL_REV bump to kernel main 80b68e1.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
The kernel owns the retry loop on the SEA/use_kernel path, so forward the
driver's existing ClientConfig retry knobs (the same ones the Thrift
HttpRetryPolicy reads) onto the napi ConnectionOptions retry kwargs — keeping
SEA and Thrift governed by one retry config. Mirrors Python connector #820.

- buildSeaRetryOptions(config): ms -> whole seconds, clamped to napi u32.
  retryDelayMin->retryMinWaitSecs, retryDelayMax->retryMaxWaitSecs,
  retriesTimeout->retryOverallTimeoutSecs, retryMaxAttempts passes through as a
  TOTAL attempt count (the kernel converts to retries-after-first).
- SeaBackend.connect() merges it into the native options from the client config.
- Adds SeaSessionDefaults retry fields + unit tests (mapping, rounding, clamp).

Requires kernel napi retry kwargs (databricks-sql-kernel #141). KERNEL_REV is
pinned to #141's branch HEAD as a placeholder — MUST be re-pinned to #141's
squash-merge SHA before this merges (orphan-SHA risk otherwise).

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…o msrathore/sea-mtls-headers-useragent

Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>

# Conflicts:
#	tests/unit/sea/connectionOptions.test.ts
…essage, diagnosticInfo, errorDetailsJson)

Ports the async rich-status work (was #422) onto the consolidated branch: the
napi Statement.status() fields the kernel already exposes are now surfaced
through getOperationStatus instead of a flat Succeeded (M1 item).

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Consolidation fixups:
- buildSeaRetryOptions now OMITS any knob the client config didn't set to a
  finite number (was emitting NaN across the FFI when getConfig() lacked retry
  fields, e.g. the fake test context). Finite negatives still clamp to 0.
- Repair the brace balance in connectionOptions.test.ts after merging the mTLS
  and retry test blocks.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
@msrathore-db msrathore-db deployed to azure-prod June 6, 2026 16:54 — with GitHub Actions Active
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@msrathore-db msrathore-db changed the title [SEA-NodeJS] Kernel backend: mTLS, custom HTTP headers & User-Agent [SEA-NodeJS] Kernel-parity batch: mTLS + custom headers/UA + retry/backoff + operation-status fields Jun 6, 2026
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.

1 participant