Repository navigation
fix(api): read the onboarding project from the request params - #14807
Conversation
The onboarding shutdown hook read projectId back from the route's param values. The route object is shared by every request in the worker, so after the hook's own I/O it could hold another request's values. The dispatch-frame params belong to the current request only.
|
Review complete. 🟠 1 high 📍 Findings outside the diff (1) — 🟠 1 high — defects on lines GitHub can't attach comments to🟠 High — Onboarding state read before lock, lost update under concurrency · api.php:1288–1339 · // app/controllers/shared/api.php
1288 $byMethod = $project->getAttribute('onboarding', []);
1289 if (! \is_array($byMethod)) {
1290 $byMethod = [];
1291 }
1292
1293 $actorType = ($apiKey !== null && $apiKey->getRole() === User::ROLE_KEYS)
1294 ? match ($apiKey->getType()) {
1295 API_KEY_ACCOUNT => ACTOR_TYPE_KEY_ACCOUNT,
1296 API_KEY_ORGANIZATION => ACTOR_TYPE_KEY_ORGANIZATION,
1297 API_KEY_STANDARD, API_KEY_EPHEMERAL => ACTOR_TYPE_KEY_PROJECT,
1298 default => ACTOR_TYPE_KEY_PROJECT,
1299 }
🧹 Nitpicks (1) — 🟢 1 low
This PR makes the
Note: the correctness, security, and api-data scans confirmed the injection wiring is behavior-preserving — Reviewed commit: 6629b26 |
🟢 Tier S · Ready to mergeThe onboarding shutdown hook now resolves the project ID from dispatch-local request params instead of mutable shared Route state. An E2E test exercises project-key creation through the console against a path project, verifies the returned key name and scopes, and waits for that project's onboarding stage to complete. Latest changes: The latest commit adds assertions that the created key response contains the requested name and scopes.
📂 Walkthrough · 2
Reviewed the commits since |
|
Thanks. The lost-update finding is about lines this PR leaves as they were: the read-modify-write of |
✨ 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
|
…t-from-request fix(api): read the onboarding project from the request params (cherry picked from commit bd8936e)
Summary
The onboarding shutdown hook in
app/controllers/shared/api.phpresolved the target project for organization routes from$route->getParamsValues(). TheRouteobject is shared by all requests in a worker process, and the framework writes each request's validated values onto it, so after the hook's own I/O the values could belong to a different request. The hook now takesprojectIdfrom the injectedparams, which come from the current dispatch frame.The framework write (
Hook::setParamValue()inpackages/http) is left in place:getParamsValues()is public API of the package and nothing in Appwrite reads it any more, so removing it is a separate, breaking change for the package.Test plan
StagesConsoleClientTest::testCreateProjectKeyFromConsoleCompletesStageOnPathProject: creating a project key through/v1/organization/projects/:projectId/keyson the console project completesorganization.createProjectKeyon the project in the pathRelated: appwrite-labs/cloud#6672