Skip to content

fix(settings): validate CLICKHOUSE_MAX_MEMORY_USAGE instead of silently ignoring invalid values - #5135

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/validate-clickhouse-max-memory-usage-w1
Jul 23, 2026
Merged

fix(settings): validate CLICKHOUSE_MAX_MEMORY_USAGE instead of silently ignoring invalid values#5135
pedrofrxncx merged 1 commit into
mainfrom
fix/validate-clickhouse-max-memory-usage-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Follows #5129 (PORT validation) and the same pattern applied to DUCKDB_THREADS in #5130resolve-config.ts has more than one env var that silently swallows a bad value instead of failing loudly.

clickhouseMaxMemoryUsage was computed as Number(envVars.CLICKHOUSE_MAX_MEMORY_USAGE) || undefined. Any non-numeric or invalid value ("abc", "-1", "1.5") silently produces NaN which then falls through || undefined, so a typo in this env var quietly disables the ClickHouse memory-limit engine option in production instead of failing startup — the same failure mode PORT and DUCKDB_THREADS just got fixed for.

Fix: added a toPositiveIntegerOrUndefined helper (same shape as the existing toPositiveIntegerOrDefault used for PORT/DATABASE_POOL_MAX) and use it for CLICKHOUSE_MAX_MEMORY_USAGE. Unset/empty still resolves to undefined (unchanged default behavior — context-factory.ts's settings.clickhouseMaxMemoryUsage ? {...} : ... check is unaffected), but an invalid value now throws "CLICKHOUSE_MAX_MEMORY_USAGE must be a positive integer" at startup instead of being silently dropped.

To verify: bun test apps/mesh/src/settings/resolve-config.test.ts

Locally ran: bun run fmt, bunx tsc --noEmit (apps/mesh workspace), and the targeted test file above — all green. Full CI validates the rest.


Summary by cubic

Validate CLICKHOUSE_MAX_MEMORY_USAGE as a positive integer and fail fast on invalid values. This prevents silently disabling the ClickHouse memory limit.

  • Bug Fixes
    • Added toPositiveIntegerOrUndefined and used it for CLICKHOUSE_MAX_MEMORY_USAGE.
    • Unset/empty stays undefined; invalid values now throw "CLICKHOUSE_MAX_MEMORY_USAGE must be a positive integer" at startup.
    • Added tests for default, valid, and invalid values in resolve-config.test.ts.

Written for commit 0205042. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 23, 2026 20:39
@pedrofrxncx
pedrofrxncx merged commit 26273c2 into main Jul 23, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/validate-clickhouse-max-memory-usage-w1 branch July 23, 2026 20:55
decocms Bot pushed a commit that referenced this pull request Jul 23, 2026
PR: #5135 fix(settings): validate CLICKHOUSE_MAX_MEMORY_USAGE instead of silently ignoring invalid values
Bump type: patch

- decocms (apps/mesh/package.json): 4.113.3 -> 4.113.4

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