Skip to content

fix(config): reject DSN timeout values that overflow time.Duration - #556

Merged
vuanhphung merged 2 commits into
mainfrom
fix/issue-490-dsn-timeout-overflow
Nov 14, 2026
Merged

vuanhphung merged 2 commits into
mainfrom
fix/issue-490-dsn-timeout-overflow

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

The DSN timeout param (seconds) was converted with time.Duration(seconds) * time.Second and no range check. Non-numeric and int64-overflowing values were rejected with an error naming timeout. Anything whose nanosecond count overflows int64 wrapped silently instead: 9223372037 became −2562047h, 9223372036854775807 became −1s (the "no timeout" spelling), 18446744074 became 290ms, and -9223372037 became +292 years.

ParseDSN now rejects values outside ±9223372036 s (math.MaxInt64/MinInt64 / time.Second) with the same request-error type and style as the existing parse error: invalid DSN: param timeout with value 9223372037 is out of range [-9223372036, 9223372036] seconds. Negative values within range, including -1, are intentionally still accepted. The DSN is the only user-supplied seconds value with this multiply pattern. WithTimeout takes a time.Duration and can't overflow, and the other * time.Second sites parse server headers or responses.

Verification: a new table-driven ParseDSN test covers 0, 1, ±9223372036 (accepted), −1 (accepted), 9223372037, MaxInt64, 18446744074 and −9223372037 (rejected, naming timeout), and the unchanged int64-overflow and non-numeric errors. Its four overflow cases fail on main. An OpenConnector test asserts the error is errors.RequestError. A live e2e on both backends opens the DSN with sql.Open and runs SELECT 1 (Thrift: timeout=60 and -1; kernel: 0 and -1), and asserts timeout=9223372037 fails at sql.Open. Both legs pass, and the Thrift e2e fails on main. make test (1317 tests), make lint (0 issues), go test -race on the touched packages, and the databricks_kernel-tagged suite all pass. The one tagged failure, TestKernelCloudFetchDisabledPreservesUnsupportedServerError, fails identically on main: it needs a KERNEL_REV newer than the v1.4.0 bindings. Performance: the change runs once per DSN parse, not on any request or fetch path.

Cross-driver state

Driver State Notes
Go Overflow wraps → rejected (this PR) DSN timeout (seconds, default none). Bound is math.MaxInt64 / time.Second; in-range negatives still accepted
JDBC Supported (type-bounded) setQueryTimeout(int) can't overflow; negatives rejected with DatabricksValidationException (DatabricksStatement.java:256 @0cb8c24)
Python Not applicable No client query-timeout option; Thrift request never sets queryTimeout (thrift_backend.py:1112-1133 @5a1a7ec)
Node.js Not supported queryTimeout goes to Int64 with no range or sign check (ThriftSessionBackend.ts:50-63, 204 @93a9112)
Kernel Supported u64 ms. Above DATABRICKS_KERNEL_MAX_CLIENT_QUERY_TIMEOUT_MS (9223372036854 = MaxInt64 ns / 1e6) returns InvalidArgument (vendored databricks_kernel.h:88-89)

This follows the kernel's model: the bound is what the host duration type can represent, and out-of-range values are rejected, not clamped. It deviates in keeping in-range negatives, which -1 users may rely on as "no timeout".

Adversarial review: converged in round 1 with no high findings; both mediums are fixed (32-bit-safe overflow assertions, kernel e2e honors the Reyden leg).

Addresses #490

This pull request and its description were written by Isaac.

@vuanhphung
vuanhphung marked this pull request as ready for review November 13, 2026 16:17

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

✅ No issues identified by the review bot.

vuanhphung and others added 2 commits November 13, 2026 23:35
ParseDSN multiplied the `timeout` seconds by time.Second without a range
check, so values beyond +/-9223372036 wrapped silently: 9223372037 became
-2562047h, 9223372036854775807 became -1s, and -9223372037 became +292y.
Reject them with a request error naming `timeout`, like non-numeric input.
In-range negative values are still accepted.

Addresses #490.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
On 32-bit platforms strconv.Atoi rejects 9223372037 before the range
check, so assert only the option name and value there. Let the kernel e2e
pass its effective HTTP path so the Reyden leg targets the Reyden
warehouse.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
@vuanhphung
vuanhphung force-pushed the fix/issue-490-dsn-timeout-overflow branch from f2a5a89 to bd7a1b3 Compare November 13, 2026 23:37

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

✅ No issues identified by the review bot.

@vuanhphung
vuanhphung enabled auto-merge November 13, 2026 23:56
@vuanhphung
vuanhphung added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 4b67686 Nov 14, 2026
14 checks passed
@vuanhphung
vuanhphung deleted the fix/issue-490-dsn-timeout-overflow branch November 14, 2026 00:09
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