Skip to content

fix(sea): input validation — empty-string metadata coercion + bind-time param guards#405

Open
msrathore-db wants to merge 1 commit into
msrathore/sea-interval-getinfo-parityfrom
msrathore/sea-input-validation
Open

fix(sea): input validation — empty-string metadata coercion + bind-time param guards#405
msrathore-db wants to merge 1 commit into
msrathore/sea-interval-getinfo-parityfrom
msrathore/sea-input-validation

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

Three SEA-adapter input-validation fixes from the jira-candidate triage. All node-layer, no kernel change, each restores parity with the Thrift backend. Stacked on #403 (where the touched files live).

1. Empty-string metadata args → coerced (parity)

(jira: 2026-05-22-sea-rejects-empty-string-args) — the kernel's Identifier/LikePattern reject "" with InvalidArgument, while Thrift treats "" as "unspecified" (match-all / session default). This diverged ~1400 metadata cases in the comparator. getSchemas/getTables/getColumns/getFunctions now emptyToUndefined("") before the napi call.
Live: getSchemas({catalogName: ''}) → returns rows (previously ParameterError).

2. Array/object param values → rejected at bind time (DoS guard)

(jira: 2026-05-25-thrift-array-ordinal-hangs) — an array bound as a parameter stringified to "1,2,3"; the server couldn't coerce it and the operation never returned to FINISHED (a denial-of-service hazard). assertBindableValue now rejects array/object values up front on both positional and named paths; scalars, Date, Int64, and DBSQLParameter are allowed.
Live: array ordinal → ParameterError, no hang.

3. Ordinal arity check (data-correctness)

(jira: 2026-05-25-thrift-ordinal-excess-silent) — excess ordinal params were silently dropped server-side (SELECT ? AS only with [1,2] returned {only:1}, second param lost). Now positionalParams.length must equal the ? marker count, via a quote/comment-aware scanner (countParameterMarkers) mirroring the kernel's count_parameter_markers (so markers inside string literals / comments aren't counted).
Live: count mismatch → ParameterError.

New module

lib/sea/SeaInputValidation.tsemptyToUndefined, countParameterMarkers, assertBindableValue.

Tests

214 sea unit tests pass. New inputValidation.test.ts (marker scanning incl. quotes/comments/escapes, bindable-value matrix) + behavior tests in execution.test.ts (empty-string coercion, array rejection, arity mismatch). All three verified live against a warehouse.

Triage note

Two other HIGH jira-candidates were validated as not real this pass and should be closed: 2026-05-20-create-schema-throws-on-sea (actually PERMISSION_DENIED on the test catalog — DDL/DML are identical on a permissioned warehouse) and 2026-05-22-list-tables-sigsegv (was the comparator's own JS stack-overflow, fixed in driver-test #420 — the kernel ran 5000+ list_tables cases clean).

This pull request and its description were written by Isaac.

…me param guards

Three SEA-adapter input-validation fixes from the jira-candidate triage, all
in the node layer (no kernel change), all parity-preserving vs the Thrift
backend:

- Metadata empty-string args (jira #2026-05-22-sea-rejects-empty-string-args):
  the kernel's Identifier/LikePattern reject "" with InvalidArgument while
  Thrift treats "" as "unspecified" (match-all/default). getSchemas/getTables/
  getColumns/getFunctions now coerce "" -> undefined before the napi call
  (emptyToUndefined), restoring Thrift parity. Live: getSchemas(catalog="")
  now returns rows instead of throwing ParameterError.

- Array/object param values (jira #2026-05-25-thrift-array-ordinal-hangs):
  an array bound as a parameter stringified to "1,2,3" and the operation
  never returned to FINISHED (DoS). Reject array/object values at bind time
  (assertBindableValue) on both positional and named paths; Date/Int64/
  scalars/DBSQLParameter are allowed.

- Ordinal arity (jira #2026-05-25-thrift-ordinal-excess-silent): excess
  ordinal params were silently dropped server-side (data-correctness footgun).
  Validate positionalParams.length === '?' marker count, with a quote/comment-
  aware scanner mirroring the kernel's count_parameter_markers.

214 sea unit tests pass; all three fixes verified live against a warehouse.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
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