fix(review): trim LOOPOVER_PUBLIC_STATS before the truthy-flag regex test - #10344
Merged
JSONbored merged 1 commit intoAug 4, 2026
Merged
Conversation
…test isPublicStatsEnabled tested the raw, untrimmed env value against the anchored /^(1|true|yes|on)$/i regex, while every sibling flag-checker in the codebase (e.g. pr-reconciliation.ts's isPrReconciliationEnabled) trims first. A trailing newline or surrounding whitespace -- plausible from wrangler secret put reading a file, or a CI/CD-injected env var carrying a trailing newline -- made the anchored regex fail to match even though the operator clearly meant to enable the flag: the test of 'true\n' was false. Trim the value before the regex, matching the established convention. The manifestOverride early-return and every already-clean value are unchanged. Closes JSONbored#10329
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
JSONbored
approved these changes
Aug 4, 2026
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
isPublicStatsEnabledchecked theLOOPOVER_PUBLIC_STATSenv flag against an anchored truthy regex on the raw, untrimmed value:Every sibling boolean-env-flag checker in the codebase trims first — e.g.
pr-reconciliation.ts'sisPrReconciliationEnabled:isPublicStatsEnabledwas the odd one out. A trailing newline or surrounding whitespace — plausible viawrangler secret putreading from a file, or CI/CD injecting an env var with a trailing newline — makes the anchored regex fail to match even though the operator clearly meant to enable the flag:/^(1|true|yes|on)$/i.test("true\n")isfalse. The sibling's trimmed behaviour is deliberately regression-tested;isPublicStatsEnabledhad no.trim()and no equivalent test.The fix
Trim
env.LOOPOVER_PUBLIC_STATSbefore the regex test, matching the established convention:Unchanged: the
manifestOverride?.presentearly-return, and every already-clean value (no leading/trailing whitespace) evaluates exactly as before — this is a whitespace-robustness fix only.Tests (
test/unit/public-stats.test.ts)isPublicStatsEnabled({ LOOPOVER_PUBLIC_STATS: "true\n" })(and" 1 ","\ton\t"," yes") now returnstrue; a whitespace-padded unrecognised value (" maybe "," false ","\n0\n") staysfalse— fails onmain."true","0","",undefined) and still passes unchanged.Validation
src/review/public-stats.tsis 100% (the.trim()line; no new branch).npm run typecheckclean;npm run engine-parity:drift-checkpasses (not a twin);npm run dead-exports:checkclean; the public-stats suite and its parity-invariant test green.git diff --checkclean; no schema/migration/generated-artifact change.Closes #10329