Skip to content

fix(http): cast loose boolean query params before actions - #14085

Open
cursor[bot] wants to merge 3 commits into
mainfrom
fix-14082-loose-boolean-cast
Open

cursor[bot] wants to merge 3 commits into
mainfrom
fix-14082-loose-boolean-cast

Conversation

@cursor

@cursor cursor Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

List endpoints accept total=false to skip the count, but official SDKs send the query string literal "false". Boolean(loose: true) accepted that string and left it unchanged; PHP then coerced the non-empty string to true for typed bool action params, so the count still ran.

This adds Validator::parse() (overridden by Boolean / delegated by Nullable) and calls it from utopia-http after validation so loose forms become real booleans before the action runs.

Test Plan

  • Unit: BooleanTest / NullableTest parse coverage
  • Unit: HttpTest::testLooseBooleanParamsAreParsedToBool for "false" / "true" / "0" / "1"
  • E2E: Account sessions list with literal ?total=false (SDK-shaped query string)

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web View Automation 

SDKs send total=false as the string "false", which Boolean(loose) accepted
but left as a non-empty string. PHP then coerced it to true for typed bool
params, so list endpoints still ran the count. Parse loose forms to real
booleans in utopia-http after validation (fixes #14082).

Co-authored-by: chiragaggarwal5k <[email protected]>
@cursor
cursor Bot requested a review from ChiragAgg5k October 4, 2026 03:38
@cursor
cursor Bot marked this pull request as ready for review October 4, 2026 03:38
@ghost

ghost commented Oct 4, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new changes preserve the intended conversion and introduce no identified defects.

Adds a validator cast() hook so accepted loose boolean query values reach HTTP actions as native booleans, fixing literal total=false being treated as true. Boolean performs the conversion and Nullable delegates while preserving null. Includes validator and HTTP unit coverage plus an account sessions E2E regression.

Latest changes: Moves casting into validate() to reuse the validated validator instance, simplifies boolean matching with strict in_array(), updates HTTP test output assertions, and adjusts the PHPStan baseline.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@cursor[bot] does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 9
File Change
packages/http/phpstan-baseline.neon Updates existing suppression counts for the added HTTP test.
packages/http/src/Http.php Casts supplied parameter values after successful validation using the same validator instance.
packages/http/tests/HttpTest.php Checks action output for loose boolean string, integer, and native boolean inputs.
packages/validators/src/Validator.php Adds an identity cast() hook without conflicting with existing static parse() helpers.
packages/validators/src/Validator/Boolean.php Converts accepted loose boolean forms to native booleans using strict matching.
packages/validators/src/Validator/Nullable.php Preserves null and delegates casting of non-null values.
packages/validators/tests/BooleanTest.php Covers casting of accepted loose boolean forms.
packages/validators/tests/NullableTest.php Covers null preservation and delegated boolean casting.
tests/e2e/Services/Account/AccountCustomClientTest.php Verifies literal total=false returns zero total without removing sessions.

Reviewed the commits since 41e1320 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔ Tier F · 1 blocking finding to address. Summary

Comment thread packages/validators/src/Validator.php Resolved
Adding Validator::parse() fatally conflicted with Appwrite's
CompoundUID::static parse(), which messaging loads at boot. Rename the
loose-value hook to cast() instead.

Co-authored-by: chiragaggarwal5k <[email protected]>
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-14082-loose-boolean-cast (after).

Metric Before After Change
🚀 Requests/sec 207.4 210.16 ⚪ +1.3%
⏱️ Latency P50 81.3 ms 81.74 ms ⚪ +0.5%
⏱️ Latency P95 202.43 ms 194.68 ms ⚪ -3.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 81.74 194.68 13,224 210.16 -7.75
Account 157.25 304.52 696 11.53 -35.18
TablesDB 79 147.93 7,192 116.94 -0.86
Storage 74.12 162.72 3,480 58.31 -0.95
Functions 117.88 248.32 1,856 31.78 -9.35

Top API waits (after)

API request Max wait (ms)
account.prefs.update 438.6
account.name.update 425.33
functions.create 398.16
functions.variables.create 390.32
functions.variables.update 386.16

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

Calling resolveValidator again after validate re-ran factory closures
(breaking HttpTest::testCanExecuteRoute). Cast loose values inside
validate via by-ref, apply Rector's in_array form in Boolean::cast,
and refresh the http phpstan baseline counts for the new test.

Co-authored-by: chiragaggarwal5k <[email protected]>

This branch has not been deployed

No deployments
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.

🐛 Bug Report: total=false on list endpoints is ignored

1 participant