Repository navigation
fix(http): resolve only registered param defaults as callables - #14792
Conversation
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.
|
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
Reviewed commit: e0bfa9b |
🟢 Tier S · Ready to merge
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.
📂 Walkthrough · 6
Reviewed |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
…ables fix(http): resolve only registered param defaults as callables (cherry picked from commit dbb99f9)
…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.
Summary
Http::getArguments()(utopia-php/http) andBase::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 forBase::prepare(), plus a check that closure defaults are still resolvedbin/monorepo test http,bin/monorepo test serversbin/monorepo check http,bin/monorepo check servers,bin/monorepo validateRelated: appwrite-labs/cloud#6674