fix(settings): validate DUCKDB_THREADS instead of silently producing NaN - #5130
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(settings): validate DUCKDB_THREADS instead of silently producing NaN#5130pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
This was referenced Jul 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug (same class as PORT/DATABASE_POOL_MAX, this tick's other session):
resolveConfigparsedDUCKDB_THREADSasenvVars.DUCKDB_THREADS ? Number(envVars.DUCKDB_THREADS) : undefined— unlikeCLICKHOUSE_MAX_MEMORY_USAGE(which falls back toundefinedvia|| undefined), an invalid value here (e.g.DUCKDB_THREADS=abc) producesNaN, which is then threaded intoDuckDBTuning.threadsand stringified into the DuckDB instancethreadsconfig (apps/mesh/src/monitoring/query-engine.ts), causing a cryptic runtime failure when the embedded monitoring DuckDB engine spins up instead of a clear startup error.A maintainer wants this because it turns a silent/cryptic monitoring-engine failure into a clear fail-fast error at config-resolution time, matching the validation already applied to
PORTandDATABASE_POOL_MAX.Fix: added
toPositiveIntegerOrUndefined(same shape as the existingtoPositiveIntegerOrDefaultbut with no default, since DuckDB threads legitimately has no numeric default — unset means "use all CPUs") and used it forDUCKDB_THREADS. Throws"DUCKDB_THREADS must be a positive integer"for non-integer/non-positive values, same as the sibling validators.Regression test: added a
describe("resolveConfig duckdb threads")block toresolve-config.test.tscovering the unset-default, valid-value, and invalid-value-throws cases (mirroring the existingDATABASE_POOL_MAX/NATS_TUNNEL_SESSION_TTL_SECONDStest blocks).Reviewer check:
bun test apps/mesh/src/settings/resolve-config.test.tsLocally ran:
bun run fmt,cd apps/mesh && bunx tsc --noEmit, and the targeted test file above (all green). Full CI validates the rest.Summary by cubic
Validate DUCKDB_THREADS during config resolution to fail fast on invalid values, preventing NaN from reaching DuckDB and causing a cryptic startup crash in the monitoring engine.
Written for commit 9bd1d79. Summary will update on new commits.