Skip to content

fix(http): resolve only registered param defaults as callables - #14792

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/http-request-callables
Oct 22, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/http-request-callables

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Http::getArguments() (utopia-php/http) and Base::prepare() (utopia-php/servers) resolved a param value by calling it whenever it was a non-string callable, regardless of where the value came from. That made the callable-default feature apply to request values too.

This limits the resolution to the default registered with param(): a value present in the request is always treated as plain data and goes straight to validation. Closure defaults keep working as before.

Test plan

  • HttpTest::testCallableArrayRequestParametersNotExecuted: a callable-shaped array sent as a request param reaches the action as data and is not invoked (fails without the fix)
  • Utopia\\Servers\\Tests\\BaseTest: same for Base::prepare(), plus a check that closure defaults are still resolved
  • bin/monorepo test http, bin/monorepo test servers
  • bin/monorepo check http, bin/monorepo check servers, bin/monorepo validate

Related: appwrite-labs/cloud#6674

Request values are data and must never be invoked, even when they happen
to be callable. Only defaults registered on the route or hook are
resolved, in both utopia-php/http and utopia-php/servers.
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR hardens parameter handling so only registered defaults may be resolved as callables; values arriving from the request are no longer candidates for call_user_func_array resolution. The same guard is applied consistently in both packages, and new tests cover callable-shaped request data being treated as plain values.

Files Change
packages/http/src/Http.php, packages/servers/src/Base.php Skip callable resolution for request-supplied params, closing the callable-injection path.
packages/http/tests/HttpTest.php, packages/servers/tests/BaseTest.php, packages/servers/tests/Server.php Add regression tests for callable-as-data behavior.
packages/http/phpstan-baseline.neon Baseline refresh.

Reviewed commit: e0bfa9b

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changes are localized, preserve callable defaults, and include regression coverage for the request-value behavior in both affected libraries.

HTTP argument parsing and server hook preparation now resolve callable values only when they come from registered parameter defaults, while callable-shaped request values remain data. Regression tests cover the request case in both packages and verify that callable defaults still resolve.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
packages/http/src/Http.php Restricts callable resolution to registered parameter defaults.
packages/http/tests/HttpTest.php Adds regression coverage for callable-array request values.
packages/http/phpstan-baseline.neon Adjusts the baseline for the added HTTP test.
packages/servers/src/Base.php Restricts callable resolution to registered hook defaults.
packages/servers/tests/BaseTest.php Tests callable request data and callable defaults.
packages/servers/tests/Server.php Adds a minimal Base subclass for preparation tests.

Reviewed e0bfa9b · 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 S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/http-request-callables (after).

Metric Before After Change
🚀 Requests/sec 205.44 208.3 ⚪ +1.4%
⏱️ Latency P50 82.96 ms 82.88 ms ⚪ -0.1%
⏱️ Latency P95 199.69 ms 192.87 ms ⚪ -3.4%
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 82.88 192.87 12,996 208.3 -6.82
Account 156.31 293.76 684 11.33 +3.32
TablesDB 79.52 145.77 7,068 115.65 -23.75
Storage 77.47 177.59 3,420 57.7 -10.96
Functions 118.85 227.99 1,824 31.58 +5.83

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.create 503.25
account.name.update 404.77
functions.variables.update 390
functions.create 378.57
account.prefs.update 354.22

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit dbb99f9 into main Oct 22, 2026
74 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/http-request-callables branch October 22, 2026 18:36
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ables

fix(http): resolve only registered param defaults as callables

(cherry picked from commit dbb99f9)
sarbojitrana pushed a commit to sarbojitrana/appwrite that referenced this pull request Nov 2, 2026
…lues (backport appwrite#14897, appwrite#14792)

Swoole accepts a Swoole-Upload-File part header as a ready temp file, so a client could name any server path as its upload and have it unlinked. The framework also calls any callable argument, so a request value such as ["Class", "method"] ran as code. The 1.9 dependency set caps utopia-php/http below the releases that fix both, so the request wrapper applies the guards.
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.

1 participant