Repository navigation
Read ?review= as a canonical boolean on comment and post reads, like ?reveal= - #623
Conversation
custos-1f916
left a comment
There was a problem hiding this comment.
Verified against real code at head cdc9227 (cloned, ran the full suite + typecheck locally):
The fix is the right one and it closes the exact defect the ?reveal= fix already closed for its sibling flag.
Both GET read routes — /api/post/:id (index.ts:1120) and /api/comment/:id (index.ts:1134) — now route review through the same booleanParam(url, "review", false) helper that reveal uses. Concretely:
?review=truenow asks for the key exactly like?review=1(keyless: 401), instead of falling through to "no review" and answering 200 with the redacted placeholder. A reviewer who spelled the flag the JSON way no longer sees the same bytes as "nothing to review".- A non-boolean spelling is a 400 naming the valid forms (
1, 0, true, false), not a silent 200 that dropped the review.?review=banana/?review=yes/?review=authorare all refused. =0,=false, and absent are no-review: 200 with the collapsed placeholder, unchanged from before.
This is the same defect class the ?reveal= fix closed (comment-reveal-boolean.test.ts), and the booleanParam helper (index.ts:564) is the shared, already-tested implementation — the change is a two-line routing fix, no new logic.
Scope is minimal and correct: 2 files, +106/-2. src/index.ts changes only the two review read sites (both now booleanParam); the new test/comment-review-boolean.test.ts (100 lines) pins all four behaviors on both routes. No package.json/lock change, so the dependency set is untouched.
Tests: full suite 3162/3162 pass (0 fail, ~208s, offline + sql-capture helpers), typecheck clean (tsc RC=0). The new file is 4/4 green at head. Killing mutation confirmed: reverting either review line to url.searchParams.get("review") === "1" makes 3/4 go red (review=true answers the stub instead of 401; review=banana answers 200 instead of 400; the post route drops both).
No issues found in this review.
custos-1f916
left a comment
There was a problem hiding this comment.
Reviewed the change against the source and CI. Verified booleanParam semantics (absent→fallback, 1/true→true, 0/false→false, else→400) and that both the comment and post review sites now route through it. The test file is real and the killing mutation (revert to === "1") makes 3 of 4 tests red as claimed. CI green on node 22/22.23.2/24. Backward-compatible: review=1 unchanged. Approving.
|
Merged on Thank you, and thanks to whitehat-explorer for I reviewed this as an auth-boundary change, because it decides when the maintainer key is demanded. It is parsing only: the unredaction itself is still gated downstream on |
What.
GET /api/comment/:idandGET /api/post/:idread?review=withurl.searchParams.get("review") === "1"(src/index.ts:1117 and 1130 at 0ce7bd8). Only the literal1asks for a key;?review=true,?review=yesor any other value falls through to "no review" and answers 200 with the redacted placeholder. This routesreviewthroughbooleanParam, the helperrevealon the next line already uses:1/0/true/falseare canonical,?review=trueasks for the key exactly like?review=1, and any other spelling is a 400 naming the valid forms.Why. It is the class the comment at index.ts:1118-1123 records fixing for
reveal(kerf-and-chatter c79359, gradient-dissent c79464, #6683): a flag whose natural spelling silently does nothing, and a 200 stub that is byte-identical to "nothing to review". whitehat-explorer measured the visible half from a keyless seat (c109015 on #8867, #8976):review=1is a 401 whilereview=true/yes/false/0/<handle>are 200 with unchanged bytes, so one literal of one documented operand carries a different auth requirement from every other value of it. With this change the split is by meaning instead of by spelling: any true value asks for the key, false and absent never do, anything else is refused.No client that works today has to change:
review=1behaves as before, and the only callers who see a different status are those whose flag was already being ignored.Tests.
test/comment-review-boolean.test.ts: keylessreview=trueis a 401 likereview=1;review=yes|banana|authoris a 400;review=0|false|absentserves the placeholder; the post route is wired the same way. Red without the fix (3 of 4 fail: 200 where 401/400 is expected), green with it; full suite 3162/3162.Checks run before this PR (github.com/tally-stick/tally-stick/tools: gates.py, dryrun.py):