Skip to content

fix(config): reject unrecognized boolean env values instead of treating them as true#59

Open
exo-nikita wants to merge 1 commit into
mainfrom
claude/stasis-core-plugins-review-wxauv4-envbool
Open

fix(config): reject unrecognized boolean env values instead of treating them as true#59
exo-nikita wants to merge 1 commit into
mainfrom
claude/stasis-core-plugins-review-wxauv4-envbool

Conversation

@exo-nikita

Copy link
Copy Markdown
Collaborator

The bug

envBool in stasis-core/src/config.js parsed EXODUS_STASIS_DEBUG / EXODUS_STASIS_CHILD_PROCESS by truthiness:

const envBool = (value) => Boolean(value && value !== '0')

Only '' and '0' read as false, so EXODUS_STASIS_CHILD_PROCESS=false (or =no, or any typo) silently enabled the toggle. Verified before the fix: falsechildProcess = true, notrue.

Why it matters

The CLI bins normalize these vars to '1'/'' before spawning, so they are unaffected — but consumers that read Config straight from the environment (the Metro transformer, standalone plugin States) get the inverted behavior: a user writing EXODUS_STASIS_CHILD_PROCESS=false to disable cross-process capture turns it on instead.

The fix

envBool(name, value) is now strict and fail-loud, matching Config's existing RangeError philosophy for invalid values:

  • '', '0', 'false' → false
  • '1', 'true' → true
  • anything else → RangeError: EXODUS_STASIS_CHILD_PROCESS must be ''/'0'/'false' or '1'/'true' (got 'no')

All call sites (constructor env-vs-option cross-checks, value resolution, loadConfig env cross-checks) pass the env var name so the error identifies the misconfigured variable. Note #env coerces '' to undefined before envBool ever runs, so '' never reaches it in practice — it is handled anyway for robustness.

Tests

Added to tests/config.test.js for both env vars, following the existing withEnv save/restore convention:

  • 'false' and '' disable (plus the pre-existing '0' cases)
  • 'true' enables (plus the pre-existing '1' cases)
  • 'no' / 'yes' throw a RangeError naming the variable

node --test tests/config.test.js: 126/126 pass. Manual probe after the fix: false/0childProcess = false, 1/truetrue, no → RangeError. The full suite has 181 pre-existing failures (missing installed deps / node version in the sandbox) with identical counts on main — none related to this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M16Lwt8cM1azwev94UP81X


Generated by Claude Code

…ng them as true

envBool parsed EXODUS_STASIS_DEBUG / EXODUS_STASIS_CHILD_PROCESS by truthiness,
so 'false', 'no', or any typo silently *enabled* the toggle. Parse strictly:
''/'0'/'false' disable, '1'/'true' enable, anything else throws a RangeError
naming the env var and the accepted values.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M16Lwt8cM1azwev94UP81X
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.

2 participants