fix(settings): validate DUCKDB_THREADS instead of silently producing NaN - #5505
Merged
Conversation
A malformed DUCKDB_THREADS ("abc", "-1", "1.5") previously flowed straight
through Number(), producing NaN in Settings and only surfacing later as an
opaque failure wherever the embedded DuckDB monitoring engine consumes
duckdbThreads. Route it through the same toPositiveIntegerOrUndefined
helper already used for CLICKHOUSE_MAX_MEMORY_USAGE and friends, so it
fails fast at startup with a clear error instead.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 31, 2026
PR: #5505 fix(settings): validate DUCKDB_THREADS instead of silently producing NaN Bump type: patch - decocms (apps/api/package.json): 4.155.0 -> 4.155.1 - @decocms/native (apps/native/package.json): 4.155.0 -> 4.155.1 Deploy-Scope: server
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.
This is the same env-var validation vein as #5473/#5476/#5463/#5379 etc:
DUCKDB_THREADSwas the last remaining hand-rolledNumber(...)inresolve-config.tswith no validation (grepped forNumber(in the file — the other two hits are already-guarded helpers). A malformed value ("abc", "-1", "1.5") silently producedNaNinSettings.duckdbThreads, which only surfaces later as an opaque failure wherever the embedded DuckDB monitoring engine consumes it, instead of failing fast at startup with a clear message.Note: an older open PR (#5130) touched this exact env var, but against the pre-rename
apps/mesh/...path, which no longer exists in this repo (renamed toapps/apimonths ago) — it can't apply as-is. This PR re-does the fix at the current path.Fix: route
DUCKDB_THREADSthrough the sametoPositiveIntegerOrUndefinedhelper already used forCLICKHOUSE_MAX_MEMORY_USAGEand other optional numeric env vars in this file, so an invalid value throws"DUCKDB_THREADS must be a positive integer"at boot instead of silently becoming NaN.Failure scenario: an operator sets
DUCKDB_THREADS=4.5(or any non-integer) in their deployment env — before this fix,Settings.duckdbThreadsbecomesNaNand the process boots successfully, only breaking later when the DuckDB monitoring engine reads it. After this fix,resolveConfigthrows immediately at startup.Test: added a
resolveConfig duckdb threadsdescribe block inresolve-config.test.tsmirroring the existingclickhouse max memory usagetest shape — covers unset (undefined default), a valid value, andit.eachover invalid values ("abc", "0", "-1", "1.5", "Infinity").Reviewer command:
bun test apps/api/src/settings/resolve-config.test.tsLocally verified:
bun run fmt,cd apps/api && bunx tsc --noEmit,bun test apps/api/src/settings/resolve-config.test.ts(87 pass),bunx oxlinton both changed files (0 warnings/errors). Full CI validates the rest.Summary by cubic
Validate the DUCKDB_THREADS env var to reject non-integer or non-positive values, so config fails fast with a clear error instead of propagating invalid numbers. Adds targeted tests and follows the existing numeric env var validation pattern.
DUCKDB_THREADSviatoPositiveIntegerOrUndefinedinresolve-config, defaulting toundefinedwhen unset and accepting integers (e.g., "4")."DUCKDB_THREADS must be a positive integer"at startup for invalid values like "abc", "0", "-1", "1.5", "Infinity".apps/api/src/settings/resolve-config.test.tscovering unset, valid, and invalid cases.Written for commit 2e92a9d. Summary will update on new commits.