P1: Validate config at startup + fix boolean env parsing (#174, #74)#193
Open
dkijania wants to merge 1 commit into
Open
P1: Validate config at startup + fix boolean env parsing (#174, #74)#193dkijania wants to merge 1 commit into
dkijania wants to merge 1 commit into
Conversation
…ing (#74) Booleans were read with ad-hoc truthiness — `if (process.env.ENABLE_LOGGING)`, `if (!process.env.ENABLE_INTROSPECTION)`, `if (!process.env.ENABLE_JAEGER ...)` — so the string "false" was truthy and *enabled* the feature. There was also no startup validation, so typos surfaced as confusing runtime behaviour. - Add `src/config.ts`: a `parseBoolean` that understands true/false, 1/0, yes/no, on/off (case-insensitive), plus `validateConfig`/`assertValidConfig` that aggregate problems (missing PG_CONN, non-numeric PORT/BLOCK_RANGE_SIZE, mistyped booleans) and fail fast with one clear message. - Route every boolean env read through `parseBoolean` (plugins, server, jaeger tracing), fixing the "false enables it" bug (#74) and making all the strict `=== 'true'` checks accept the same spellings. - Call `assertValidConfig()` first thing at startup. Unit tests cover boolean spellings (incl. the "false" case), each validation rule, error aggregation, and the throwing behaviour. Closes #174. Closes #74. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSuak9smCHbp4N17xjjLF6
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.
What & why
Part of the production-readiness epic (#163). Closes #174, closes #74.
Two problems:
if (process.env.ENABLE_LOGGING),if (!process.env.ENABLE_INTROSPECTION),if (!process.env.ENABLE_JAEGER ...). The string"false"is truthy, soENABLE_LOGGING=falseenabled logging,ENABLE_JAEGER=falseenabled tracing, etc.PG_CONN, non-numericPORT) surfaced as confusing runtime behaviour instead of failing fast.Changes
src/config.ts:parseBoolean— understandstrue/false,1/0,yes/no,on/off(case-insensitive); unrecognised/empty → fallback.validateConfig/assertValidConfig— aggregate problems (missingPG_CONN, non-positive-integerPORT/BLOCK_RANGE_SIZE, mistyped booleans) and throw one clear message.parseBoolean(plugins.ts,server.ts,jaeger-tracing.ts) — fixes Fix Boolean env vars parsing #74 and makes the previously-strict=== 'true'checks accept the same spellings.assertValidConfig()runs first thing at startup, so misconfig fails fast.Testing
npm run build— cleannpm run test:unit— all pass; 11 new assertions covering boolean spellings (incl. the"false"case), each validation rule, error aggregation, and the thrownpm run lint/npx prettier --debug-check .— clean🤖 Generated with Claude Code