Skip to content

fix(settings): validate DUCKDB_THREADS instead of silently producing NaN - #5505

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/duckdb-threads-validation-w2
Jul 31, 2026
Merged

fix(settings): validate DUCKDB_THREADS instead of silently producing NaN#5505
pedrofrxncx merged 1 commit into
mainfrom
fix/duckdb-threads-validation-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This is the same env-var validation vein as #5473/#5476/#5463/#5379 etc: DUCKDB_THREADS was the last remaining hand-rolled Number(...) in resolve-config.ts with no validation (grepped for Number( in the file — the other two hits are already-guarded helpers). A malformed value ("abc", "-1", "1.5") silently produced NaN in Settings.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 to apps/api months ago) — it can't apply as-is. This PR re-does the fix at the current path.

Fix: route DUCKDB_THREADS through the same toPositiveIntegerOrUndefined helper already used for CLICKHOUSE_MAX_MEMORY_USAGE and 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.duckdbThreads becomes NaN and the process boots successfully, only breaking later when the DuckDB monitoring engine reads it. After this fix, resolveConfig throws immediately at startup.

Test: added a resolveConfig duckdb threads describe block in resolve-config.test.ts mirroring the existing clickhouse max memory usage test shape — covers unset (undefined default), a valid value, and it.each over invalid values ("abc", "0", "-1", "1.5", "Infinity").

Reviewer command: bun test apps/api/src/settings/resolve-config.test.ts

Locally verified: bun run fmt, cd apps/api && bunx tsc --noEmit, bun test apps/api/src/settings/resolve-config.test.ts (87 pass), bunx oxlint on 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.

  • Bug Fixes
    • Parse DUCKDB_THREADS via toPositiveIntegerOrUndefined in resolve-config, defaulting to undefined when unset and accepting integers (e.g., "4").
    • Throw "DUCKDB_THREADS must be a positive integer" at startup for invalid values like "abc", "0", "-1", "1.5", "Infinity".
    • Added tests in apps/api/src/settings/resolve-config.test.ts covering unset, valid, and invalid cases.

Written for commit 2e92a9d. Summary will update on new commits.

Review in cubic

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.
@pedrofrxncx
pedrofrxncx merged commit b27fac0 into main Jul 31, 2026
26 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/duckdb-threads-validation-w2 branch July 31, 2026 17:46
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
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