Repository navigation
fix(api): pass loose boolean query params to actions as bools - #14551
Conversation
Query string values always arrive as strings. A param validated by Boolean(true) accepts "true", "false", "1" and "0" but used to reach the action unchanged, and since Http.php is not strict_types PHP casts the string at the `bool` argument: any non-empty string except "0" becomes true. So `?total=false` computed the count while `?total=0` did not, and the same held for every Boolean query param, not only `total`. The http dispatcher now converts those four strings to real bools after validation when the param's validator, unwrapped from Nullable and resolved if it is a factory, is Boolean. This mirrors the coercion the CLI dispatcher already does for getopt input. Other validators, defaults and non-string values pass through untouched. The existing E2E coverage missed this because the test client builds query strings with http_build_query, which encodes false as "0". The new E2E tests send the literal strings on documents, rows and users lists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rning Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — approved ✅; 3 nitpicks below. 🧹 Nitpicks (3) — 🟢 3 low
This PR introduces a
Reviewed commit: 0bbad81 |
🟢 Tier S · Ready to merge
The HTTP dispatcher now passes recognized loose-Boolean values to actions as native booleans, including nullable and factory-built validators. Unit and E2E tests cover the conversion and its pass-through cases, and the legacy route accessor test ignores deprecation notices. Latest changes: The newest commits move coercion into the validation path, convert integer
📂 Walkthrough · 6
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…ched A loose Boolean validator also accepts the integers 1 and 0 a JSON body sends, so they now reach the action as bools like their string forms. A param that opts out of validation is no longer coerced, since its validator never ran. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@tenki-reviewer thanks, all three nitpicks are handled in
All three new tests fail without the fix and pass with it. 🤖 Addressed by Claude Code |
|
Review complete. No issues found — approved ✅. This PR teaches the Utopia HTTP layer to coerce string query parameters to real booleans before a Boolean-validated param reaches the action, so
Reviewed commit: 067814c |
What
?total=falseon a list endpoint was ignored: the total was still computed.?total=0worked.Why
Query string values always arrive as strings. A param validated by a loose
Booleanvalidator accepts"true","false","1"and"0", but the string reached the action unchanged.Http.phpisn'tstrict_types, so PHP cast it at theboolargument: every non-empty string except"0"becametrue. This affects every loose Boolean query param, not onlytotal.Fix
After validation, the http dispatcher converts those four strings to real bools when the param's validator is
Boolean. It unwrapsNullableand resolves factory validators first. This mirrors what the CLI dispatcher already does for getopt input. Other validators, defaults and non-string values pass through untouched.Tests
packages/httpunit tests cover each literal across plain, nullable and factory-built Boolean params, plus pass-through for other validators. They fail without the fix.total=false/total=truestrings on document, row and user lists. The existing E2E client builds query strings withhttp_build_query, which encodesfalseas"0", so the old tests never hit this path.Route::getMethod()test with#[IgnoreDeprecations], so the http suite runs without deprecation warnings.🤖 Generated with Claude Code