Skip to content

Feat: public platform API#11615

Open
Meldiron wants to merge 14 commits into1.9.xfrom
feat-public-platform-api
Open

Feat: public platform API#11615
Meldiron wants to merge 14 commits into1.9.xfrom
feat-public-platform-api

Conversation

@Meldiron
Copy link
Contributor

@Meldiron Meldiron commented Mar 23, 2026

What does this PR do?

Platform APIs to be public under Project API

Test Plan

  • New tests

Related PRs and Issues

x

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?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added two new platform error constants and their HTTP mappings. Removed the legacy /v1/projects/:projectId/platforms routes from the projects controller. Introduced new platform types and constant TYPE_REACT_NATIVE_WEB. Replaced the single Platform response model with PlatformBase, PlatformWeb, PlatformApp, and PlatformList, updated response model constants, and wired those models in init. Added Platforms query validator and request/response normalization for platform endpoints. Implemented multiple new platform HTTP actions (create/update/get/delete for web and app, list, delete) and registered them in the platform HTTP service. OpenAPI/Swagger and SDK format generation now skip hidden fields. Tests add a response-format header for platform requests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feat: public platform API' accurately describes the main change: exposing Platform APIs as public under the Project API.
Description check ✅ Passed The PR description clearly states the purpose: 'Platform APIs to be public under Project API', which directly relates to the changeset that exposes platform APIs as public endpoints under the Project API.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-public-platform-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR refactors the platform management API from admin-only endpoints in app/controllers/api/projects.php into a new public Project API module, split into dedicated Web and App platform actions accessible by both admin and API key auth. It also introduces two new response models (PlatformApp, PlatformWeb), backward-compat filters for v1.8 → v1.9, and adds the new TYPE_REACT_NATIVE_WEB platform type.

Key issues found:

  • Fatal PHP error at class-load time — Both PlatformApp and PlatformWeb initialize their conditions property using self::getSupportedTypes(), a static method call. PHP requires property default values to be constant expressions; method calls are forbidden and will produce Fatal error: Constant expression contains invalid operations, preventing the application from booting. Every other polymorphic model in the codebase (e.g. AttributeFloat, AttributeEnum) uses class constants or scalar literals instead. The fix is to move the assignment into each class's constructor or inline the literal strings.
  • Required identifier/hostname in update endpointsApp/Update.php and Web/Update.php do not mark identifier and hostname as optional. On a PUT endpoint this forces callers to re-supply these fields even when only name should change, which is a usability regression from the old API where the equivalent key and hostname parameters were optional.
  • Query filter exposes DB-internal field namePlatforms.php lists key as an allowed query attribute, but the API surface uses identifier. The TODO comment in the file acknowledges this mismatch; it should be resolved before the endpoint ships.
  • Minor typo"coresponding""corresponding" in the new error description in errors.php.

Confidence Score: 1/5

  • Not safe to merge — the conditions property initializer in both new platform models will cause a PHP fatal error that prevents the application from loading.
  • The conditions = [... self::getSupportedTypes() ...] pattern in PlatformApp and PlatformWeb violates a fundamental PHP rule: property default values must be constant expressions. This is a boot-time fatal error, not a runtime edge case. Additionally, the previously-flagged issues (ignored platformId, wrong identifier field name in update) appear resolved in this revision, but the conditions bug and the optional-parameter regression still need attention before this can safely land.
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php and src/Appwrite/Utopia/Response/Model/PlatformWeb.php (fatal error on class load); src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php and Web/Update.php (optional parameter regression).

Important Files Changed

Filename Overview
src/Appwrite/Utopia/Response/Model/PlatformApp.php New polymorphic response model for app platforms; conditions property uses a static method call (self::getSupportedTypes()) as its initializer, which is not a constant expression in PHP and will cause a fatal error at class-load time.
src/Appwrite/Utopia/Response/Model/PlatformWeb.php New polymorphic response model for web platforms; identical fatal-error risk as PlatformApp — conditions property also uses self::getSupportedTypes() in the initializer.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php Update action for app platforms; correctly uses the DB field name key in the update document (fixing the issue noted in prior review), but identifier is not marked optional, which is a usability regression vs the old API.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Update.php Update action for web platforms; hostname is not marked optional, mirroring the same usability concern as App/Update.php.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php Create action for app platforms; platformId is correctly propagated to the Document constructor (fixing the previously-noted ID-ignored bug), and duplicate exception is properly caught.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php Create action for web platforms; platformId is correctly used, and the new TYPE_REACT_NATIVE_WEB type is included in supported types. Looks correct.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php List platforms action; properly scoped to the current project via projectInternalId, supports pagination queries and cursor-based paging. No issues found.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php Get platform action; type-based dispatch between MODEL_PLATFORM_WEB and MODEL_PLATFORM_APP looks correct. Unsupported types throw GENERAL_UNKNOWN, which is a reasonable fallback.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Delete.php Delete platform action; ownership check and deletion look correct. No issues found.
src/Appwrite/Utopia/Response/Model/PlatformList.php New PlatformList response model; correctly declares a polymorphic platforms array rule with both MODEL_PLATFORM_WEB and MODEL_PLATFORM_APP — model dispatching will depend on the conditions fix in PlatformApp/PlatformWeb.
src/Appwrite/Utopia/Request/Filters/V21.php Backward compat request filter for v1.8 → v1.9; correctly maps key to identifier and fills in platformId for old clients. The preservePlatformsQueries helper injects a 5000-item limit for old list calls.
src/Appwrite/Utopia/Response/Filters/V21.php Backward compat response filter; maps identifier back to key for old clients. The store field is intentionally not restored (noted in comment); old clients that relied on store will receive null.
src/Appwrite/Utopia/Database/Validator/Queries/Platforms.php Query validator for platforms; exposes internal DB column name key instead of the API field name identifier, causing a mismatch that prevents useful filtering. A TODO acknowledges this but it is unresolved.
app/config/errors.php Added two new error codes (PLATFORM_METHOD_UNSUPPORTED, PLATFORM_ALREADY_EXISTS) with correct HTTP status codes; minor typo "coresponding" → "corresponding" in the description.
src/Appwrite/Utopia/Response/Model/PlatformBase.php New abstract base model for platforms; defines shared fields ($id, $createdAt, $updatedAt, name). Clean and minimal as expected.

Reviews (3): Last reviewed commit: "fix multi-model conditions" | Re-trigger Greptile

@github-actions
Copy link

github-actions bot commented Mar 23, 2026

✨ Benchmark results

  • Requests per second: 1,496
  • Requests with 200 status code: 269,265
  • P99 latency: 0.115954918

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,496 1,067
200 269,265 192,124
P99 0.115954918 0.216117689

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (5)
src/Appwrite/Utopia/Response/Filters/V21.php (1)

55-64: Misleading comment and potential over-application of transformation.

The comment on line 57 mentions "httpUser, httpPass, store removed" but no corresponding unset() calls exist—these are handled at the model level (see PlatformApp::filter()), not in this filter.

Additionally, parsePlatform() is applied uniformly to both MODEL_PLATFORM_WEB and MODEL_PLATFORM_APP items. Web platforms don't have an identifier field (they use hostname), so the identifier -> key mapping only applies to app platforms. The null coalescing handles this gracefully, but consider:

  1. Removing or correcting the misleading comment
  2. Adding a brief comment explaining the null coalescing handles platform type differences
📝 Suggested clarification
 protected function parsePlatform(array $content): array
 {
-    // httpUser, httpPass, store removed
-
-    // identifier -> key
+    // Map 'identifier' back to 'key' for backward compatibility.
+    // App platforms have 'identifier'; web platforms don't, so we fallback to existing 'key'.
     $content['key'] = $content['identifier'] ?? $content['key'] ?? null;
     unset($content['identifier']);

     return $content;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Filters/V21.php` around lines 55 - 64, Update
parsePlatform() in V21.php to remove or correct the misleading "httpUser,
httpPass, store removed" comment (those unsets are done in
PlatformApp::filter()), and replace it with a brief note that the
identifier->key mapping uses null coalescing to safely handle both
MODEL_PLATFORM_APP (which may have identifier) and MODEL_PLATFORM_WEB (which
uses hostname), so no additional unsets are required; reference parsePlatform()
and PlatformApp::filter() in the comment for clarity.
src/Appwrite/Utopia/Database/Validator/Queries/Platforms.php (1)

11-11: Address the TODO comment for API consistency.

The TODO indicates that the API should name this field identifier instead of key. This should be tracked and addressed before the API becomes public to avoid breaking changes later.

Would you like me to open an issue to track this API naming inconsistency?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Database/Validator/Queries/Platforms.php` at line 11,
Change the API field name from 'key' to 'identifier' in the Platforms validator
by replacing the string 'key' in Validator/Queries/Platforms.php and then update
all related spots that reference this symbol: validation rules, DTOs/models,
serializers, database schema/migrations, unit/integration tests, and API docs.
To avoid breaking consumers, add a backward-compatible normalization step (e.g.,
in the request normalization or a function like normalizePlatformInput) that
accepts the deprecated 'key' and maps it to 'identifier' while emitting a
deprecation warning/log, and include a migration note and test that both 'key'
(deprecated) and 'identifier' are accepted until the old name is removed.
src/Appwrite/Utopia/Request/Filters/V21.php (1)

14-38: Add regression coverage for the new platform V21 mappings.

This switch now defines the backward-compatibility contract for platform create/update/list requests, and the PR objective says no tests were added yet. A small matrix around platformId defaulting, keyidentifier, store stripping, and the default queries branch would catch most regressions here.

Also applies to: 93-121

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Request/Filters/V21.php` around lines 14 - 38, Add
regression tests covering the V21 platform mappings: for
project.createWebPlatform/project.createAppPlatform and
project.updateWebPlatform/project.updateAppPlatform ensure fillPlatformId
behavior (platformId defaulting), that 'store' is removed, and 'key' is migrated
to 'identifier' (including when identifier already exists). Also add tests for
project.listPlatforms to assert preservePlatformsQueries behavior for default
queries. Target the code paths that invoke fillPlatformId and
preservePlatformsQueries so changes to those methods or these switch cases will
be caught.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php (1)

76-84: Avoid using the Create actions as the platform-type registry.

Get now depends on Web\Create::getSupportedTypes() / App\Create::getSupportedTypes(), while PlatformWeb and PlatformApp already keep their own lists. If one copy changes without the others, a valid platform can start failing here with GENERAL_UNKNOWN. Please move this mapping behind a shared helper or the response models.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php` around
lines 76 - 84, The Get handler currently uses
WebPlatformCreate::getSupportedTypes() and
AppPlatformCreate::getSupportedTypes() to decide the response model, which
duplicates the platform-type registry and risks drift; replace that dependency
with the canonical source (PlatformWeb and PlatformApp) or a new shared
registry/helper: call PlatformWeb::getSupportedTypes() and
PlatformApp::getSupportedTypes() (or create a
PlatformTypes::getWebTypes()/getAppTypes() helper and use it here) and map those
results to Response::MODEL_PLATFORM_WEB / Response::MODEL_PLATFORM_APP, throwing
the same Exception only if the type is absent from the shared registry.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php (1)

56-69: Parameter name inconsistency: total vs $includeTotal.

The param is defined as total on line 56, but the action method parameter is $includeTotal on line 69. While the framework likely handles this mapping, maintaining consistent naming improves readability.

♻️ Suggested rename for consistency
-    ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
+    ->param('includeTotal', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`
around lines 56 - 69, Rename the action method parameter to match the declared
param name to improve clarity: change the method signature in XList::action to
use $total (or alternatively rename the param declaration from 'total' to
'includeTotal') so both sides match; update all uses inside the action()
implementation to reference the chosen name (e.g., XList::action(array $queries,
bool $total, ...)) and ensure dependency injection mapping via ->param('total',
...) stays consistent with this identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`:
- Around line 109-112: The code computes $platformId (using ($platformId ==
'unique()') ? ID::unique() : $platformId) but then discards it by passing
ID::unique() again when constructing the Document; update the Document creation
to use the previously resolved $platformId (i.e., set '$id' => $platformId) so
user-provided IDs are honored and only generate a new ID when $platformId was
the 'unique()' sentinel; check the Document instantiation site (variable
$platform) and remove the extra ID::unique() call.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php`:
- Around line 82-85: The update Document in Update.php incorrectly uses
'identifier' instead of the schema field 'key'; update the $updates = new
Document([...]) construction in the Update class/method to set 'key' =>
$identifier (or rename the variable to $key if appropriate) so the database
field matches the schema used in App/Create.php and the update actually persists
the identifier value.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php`:
- Around line 100-103: The code computes $platformId but then discards it by
calling ID::unique() when constructing the Document; update the Document
creation in Create.php (the new Document([... '$id' => ...]) call) to use the
previously computed $platformId (keeping the existing ($platformId ==
'unique()') ? ID::unique() : $platformId logic) so user-supplied IDs are
preserved and only the literal 'unique()' string generates a new ID.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Update.php`:
- Around line 57-58: The update handler is always including hostname (from the
->param('hostname', ...) declaration) in the $updates payload which clears the
stored value when the client omits that field; change the logic that builds the
$updates Document so it only adds 'hostname' when the request actually provided
it (i.e., check presence/nullity of the incoming param before adding to
$updates), and apply the same conditional inclusion to the other optional fields
referenced around lines 83-86 so partial updates only send changed attributes.
- Around line 77-81: The Web update route currently allows any platform for the
project, which lets app platform IDs be processed; update the validation in
Update.php after retrieving $platform (via $authorization->skip and
$dbForPlatform->getDocument) to also check the platform's stored 'type'
attribute against the allowed web types (the set used to serialize to
MODEL_PLATFORM_WEB) and reject non-web types by throwing
Exception::PLATFORM_NOT_FOUND (or an appropriate error) if the type is not in
the web-supported set; ensure this check occurs before any hostname
write/serialization logic that uses MODEL_PLATFORM_WEB.

In `@src/Appwrite/Utopia/Response.php`:
- Around line 249-251: The Project model references a removed constant
Response::MODEL_PLATFORM; update the rule definition in
src/Appwrite/Utopia/Response/Model/Project.php where addRule('platforms', ...)
is configured to use the existing constant Response::MODEL_PLATFORM_LIST instead
of Response::MODEL_PLATFORM so the platforms rule points to the correct model
constant (replace Response::MODEL_PLATFORM with Response::MODEL_PLATFORM_LIST in
the addRule call).

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php`:
- Around line 38-44: The enum definitions in the Platform models wrap
getSupportedTypes() in an extra array, producing a nested array; update the
'type' rule in both PlatformApp and PlatformWeb so the 'enum' value is the flat
array returned by $this->getSupportedTypes() (i.e., change 'enum' =>
[$this->getSupportedTypes()] to 'enum' => $this->getSupportedTypes()) so
consumers receive ['value1','value2'] instead of [['value1','value2']]; modify
the rule in the methods that build the schema where the 'type' rule is defined
(referencing the getSupportedTypes() call and the 'enum' key).

In `@src/Appwrite/Utopia/Response/Model/PlatformList.php`:
- Around line 13-17: Update the description text for the 'total' rule in
PlatformList so it correctly reflects that platforms belong to a project, not a
table: locate the addRule call for 'total' in class PlatformList (the rule entry
with 'type' => self::TYPE_INTEGER and 'example' => 5) and change the
'description' value from "Total number of platforms in the given table." to
"Total number of platforms in the given project."

In `@src/Appwrite/Utopia/Response/Model/PlatformWeb.php`:
- Around line 27-33: The enum rule for the 'type' field incorrectly wraps
$this->getSupportedTypes() inside another array (creating a nested array) in
PlatformWeb.php (within the rule block that calls ->addRule('type', ...)), which
breaks validation; change the 'enum' value to use the flat array returned by
getSupportedTypes() (i.e., 'enum' => $this->getSupportedTypes()), and apply the
same fix to the identical pattern in PlatformApp.php so both use the flat list
rather than an array-wrapped list.

---

Nitpick comments:
In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php`:
- Around line 76-84: The Get handler currently uses
WebPlatformCreate::getSupportedTypes() and
AppPlatformCreate::getSupportedTypes() to decide the response model, which
duplicates the platform-type registry and risks drift; replace that dependency
with the canonical source (PlatformWeb and PlatformApp) or a new shared
registry/helper: call PlatformWeb::getSupportedTypes() and
PlatformApp::getSupportedTypes() (or create a
PlatformTypes::getWebTypes()/getAppTypes() helper and use it here) and map those
results to Response::MODEL_PLATFORM_WEB / Response::MODEL_PLATFORM_APP, throwing
the same Exception only if the type is absent from the shared registry.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`:
- Around line 56-69: Rename the action method parameter to match the declared
param name to improve clarity: change the method signature in XList::action to
use $total (or alternatively rename the param declaration from 'total' to
'includeTotal') so both sides match; update all uses inside the action()
implementation to reference the chosen name (e.g., XList::action(array $queries,
bool $total, ...)) and ensure dependency injection mapping via ->param('total',
...) stays consistent with this identifier.

In `@src/Appwrite/Utopia/Database/Validator/Queries/Platforms.php`:
- Line 11: Change the API field name from 'key' to 'identifier' in the Platforms
validator by replacing the string 'key' in Validator/Queries/Platforms.php and
then update all related spots that reference this symbol: validation rules,
DTOs/models, serializers, database schema/migrations, unit/integration tests,
and API docs. To avoid breaking consumers, add a backward-compatible
normalization step (e.g., in the request normalization or a function like
normalizePlatformInput) that accepts the deprecated 'key' and maps it to
'identifier' while emitting a deprecation warning/log, and include a migration
note and test that both 'key' (deprecated) and 'identifier' are accepted until
the old name is removed.

In `@src/Appwrite/Utopia/Request/Filters/V21.php`:
- Around line 14-38: Add regression tests covering the V21 platform mappings:
for project.createWebPlatform/project.createAppPlatform and
project.updateWebPlatform/project.updateAppPlatform ensure fillPlatformId
behavior (platformId defaulting), that 'store' is removed, and 'key' is migrated
to 'identifier' (including when identifier already exists). Also add tests for
project.listPlatforms to assert preservePlatformsQueries behavior for default
queries. Target the code paths that invoke fillPlatformId and
preservePlatformsQueries so changes to those methods or these switch cases will
be caught.

In `@src/Appwrite/Utopia/Response/Filters/V21.php`:
- Around line 55-64: Update parsePlatform() in V21.php to remove or correct the
misleading "httpUser, httpPass, store removed" comment (those unsets are done in
PlatformApp::filter()), and replace it with a brief note that the
identifier->key mapping uses null coalescing to safely handle both
MODEL_PLATFORM_APP (which may have identifier) and MODEL_PLATFORM_WEB (which
uses hostname), so no additional unsets are required; reference parsePlatform()
and PlatformApp::filter() in the comment for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2cdd31e7-32dc-4ad5-9297-b86bd20d5a11

📥 Commits

Reviewing files that changed from the base of the PR and between 995deea and d3c5a42.

📒 Files selected for processing (23)
  • app/config/errors.php
  • app/controllers/api/projects.php
  • app/init/models.php
  • src/Appwrite/Extend/Exception.php
  • src/Appwrite/Network/Platform.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Delete.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Update.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php
  • src/Appwrite/Platform/Modules/Project/Services/Http.php
  • src/Appwrite/Utopia/Database/Validator/Queries/Platforms.php
  • src/Appwrite/Utopia/Request/Filters/V21.php
  • src/Appwrite/Utopia/Response.php
  • src/Appwrite/Utopia/Response/Filters/V21.php
  • src/Appwrite/Utopia/Response/Model/Platform.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Utopia/Response/Model/PlatformBase.php
  • src/Appwrite/Utopia/Response/Model/PlatformList.php
  • src/Appwrite/Utopia/Response/Model/PlatformWeb.php
  • src/Appwrite/Utopia/Response/Model/Webhook.php
💤 Files with no reviewable changes (3)
  • src/Appwrite/Utopia/Response/Model/Webhook.php
  • src/Appwrite/Utopia/Response/Model/Platform.php
  • app/controllers/api/projects.php

@Meldiron
Copy link
Contributor Author

@greptile

@github-actions
Copy link

github-actions bot commented Mar 23, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit e5841c4 - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.42s Logs
FunctionsScheduleTest::testCreateScheduledAtExecution 1 127.41s Logs
Commit 094cd18 - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.11s Logs
FunctionsScheduleTest::testCreateScheduledAtExecution 1 132.61s Logs
Commit a06aaaf - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.05s Logs
FunctionsScheduleTest::testCreateScheduledAtExecution 1 127.14s Logs
Commit ae99d59 - 3 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.12s Logs
TablesDBCustomServerTest::testOrQueries 1 240.62s Logs
TablesDBACIDTest::testDurability 1 240.51s Logs
Commit 0d6d6a0 - 3 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.60s Logs
TablesDBConsoleClientTest::testTimeout 1 121.90s Logs
TablesDBCustomClientTest::testTimeout 1 121.07s Logs

Note: Flaky test results are tracked for the last 5 commits

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php (1)

1-1: Consider adding strict type declaration.

Per coding guidelines, strict type declarations should be used where applicable. Adding declare(strict_types=1); after the opening PHP tag improves type safety.

Suggested change
 <?php
+
+declare(strict_types=1);

 namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms\App;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`
at line 1, Add a strict types declaration to the PHP file by inserting
declare(strict_types=1); immediately after the opening <?php tag in Create.php
so the Create class and its functions enforce strict typing; ensure it appears
before any namespace or use statements to comply with PHP requirements.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Utopia/Response/Model/Project.php`:
- Around line 185-188: The union resolver cannot discriminate platform instances
because PlatformWeb and PlatformApp inherit an empty conditions array; update
the PlatformWeb and PlatformApp model classes to define a conditions array that
checks the document's "type" value: in PlatformWeb set conditions to match
["web","flutter-web","react-native-web"] and in PlatformApp set conditions to
match
["flutter-ios","flutter-android","flutter-linux","flutter-macos","flutter-windows","apple-ios","apple-macos","apple-watchos","apple-tvos","android","unity","react-native-ios","react-native-android"];
ensure these are assigned to the models' conditions property (used by
Response::union resolver that iterates $rule['type'] and calls
$this->getModel(...)->conditions) so the serializer can resolve the correct
model for the platforms union.

---

Nitpick comments:
In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`:
- Line 1: Add a strict types declaration to the PHP file by inserting
declare(strict_types=1); immediately after the opening <?php tag in Create.php
so the Create class and its functions enforce strict typing; ensure it appears
before any namespace or use statements to comply with PHP requirements.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 140df0b0-2a04-4d26-beb2-78194f1cac8e

📥 Commits

Reviewing files that changed from the base of the PR and between d3c5a42 and 39f2d24.

📒 Files selected for processing (10)
  • app/config/errors.php
  • src/Appwrite/Extend/Exception.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Update.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Utopia/Response/Model/PlatformList.php
  • src/Appwrite/Utopia/Response/Model/PlatformWeb.php
  • src/Appwrite/Utopia/Response/Model/Project.php
✅ Files skipped from review due to trivial changes (2)
  • src/Appwrite/Extend/Exception.php
  • src/Appwrite/Utopia/Response/Model/PlatformList.php
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Update.php
  • src/Appwrite/Utopia/Response/Model/PlatformWeb.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php
  • app/config/errors.php

@Meldiron
Copy link
Contributor Author

@greptile

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
src/Appwrite/Utopia/Response/Model/PlatformApp.php (2)

78-82: Fix incorrect PHPDoc comment.

The PHPDoc says "Get Collection" but this is the filter() method that transforms document attributes.

     /**
-     * Get Collection
+     * Filter document attributes for API response.
      *
-     * `@return` Document
+     * `@param` Document $document
+     * `@return` Document The filtered document
      */
     public function filter(Document $document): Document
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php` around lines 78 - 82, The
PHPDoc above the filter() method is incorrect; replace the description "Get
Collection" with a correct summary like "Filter/transform document attributes"
(or similar) and ensure the PHPDoc accurately describes the filter(Document
$document): Document behavior and return type Document to match the method
signature; update any param/return annotations to reference Document and briefly
state that this method maps/transforms document attributes before returning.

1-8: Consider adding strict type declaration.

Similar to PlatformBase, this file would benefit from declare(strict_types=1);.

 <?php
+
+declare(strict_types=1);

 namespace Appwrite\Utopia\Response\Model;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php` around lines 1 - 8, Add a
strict types declaration to this file by inserting declare(strict_types=1);
immediately after the opening <?php tag and before the namespace declaration so
PlatformApp uses strict typing like PlatformBase; update the top of
src/Appwrite/Utopia/Response/Model/PlatformApp.php to include this declaration
to enforce strict scalar type checks for the model code (e.g., class symbols in
this file such as the PlatformApp model).
src/Appwrite/Utopia/Response/Model/PlatformWeb.php (1)

1-7: Consider adding strict type declaration.

 <?php
+
+declare(strict_types=1);

 namespace Appwrite\Utopia\Response\Model;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformWeb.php` around lines 1 - 7, Add a
strict types declaration to this PHP file by inserting declare(strict_types=1);
immediately after the opening <?php tag in
src/Appwrite/Utopia/Response/Model/PlatformWeb.php so the file (and the
PlatformWeb class and any functions/methods within) will enforce strict typing
at runtime.
src/Appwrite/Utopia/Response/Model/PlatformBase.php (1)

1-6: Consider adding strict type declaration.

The file is missing declare(strict_types=1); which is recommended per coding guidelines for PHP files where applicable.

 <?php
+
+declare(strict_types=1);

 namespace Appwrite\Utopia\Response\Model;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformBase.php` around lines 1 - 6, Add
a strict types declaration to this PHP file by inserting
declare(strict_types=1); immediately after the opening <?php tag in
src/Appwrite/Utopia/Response/Model/PlatformBase.php so that the namespace
Appwrite\Utopia\Response\Model and the Model/PlatformBase class (or any
functions/types in this file) are evaluated under strict typing rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php`:
- Around line 78-82: The PHPDoc above the filter() method is incorrect; replace
the description "Get Collection" with a correct summary like "Filter/transform
document attributes" (or similar) and ensure the PHPDoc accurately describes the
filter(Document $document): Document behavior and return type Document to match
the method signature; update any param/return annotations to reference Document
and briefly state that this method maps/transforms document attributes before
returning.
- Around line 1-8: Add a strict types declaration to this file by inserting
declare(strict_types=1); immediately after the opening <?php tag and before the
namespace declaration so PlatformApp uses strict typing like PlatformBase;
update the top of src/Appwrite/Utopia/Response/Model/PlatformApp.php to include
this declaration to enforce strict scalar type checks for the model code (e.g.,
class symbols in this file such as the PlatformApp model).

In `@src/Appwrite/Utopia/Response/Model/PlatformBase.php`:
- Around line 1-6: Add a strict types declaration to this PHP file by inserting
declare(strict_types=1); immediately after the opening <?php tag in
src/Appwrite/Utopia/Response/Model/PlatformBase.php so that the namespace
Appwrite\Utopia\Response\Model and the Model/PlatformBase class (or any
functions/types in this file) are evaluated under strict typing rules.

In `@src/Appwrite/Utopia/Response/Model/PlatformWeb.php`:
- Around line 1-7: Add a strict types declaration to this PHP file by inserting
declare(strict_types=1); immediately after the opening <?php tag in
src/Appwrite/Utopia/Response/Model/PlatformWeb.php so the file (and the
PlatformWeb class and any functions/methods within) will enforce strict typing
at runtime.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fb7a8990-884b-4a23-8d79-e995e68c81b6

📥 Commits

Reviewing files that changed from the base of the PR and between 39f2d24 and 8ccf509.

📒 Files selected for processing (4)
  • src/Appwrite/Utopia/Response.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Utopia/Response/Model/PlatformBase.php
  • src/Appwrite/Utopia/Response/Model/PlatformWeb.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Appwrite/Utopia/Response.php

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
src/Appwrite/Utopia/Response/Model/PlatformWeb.php (1)

1-8: Add declare(strict_types=1); to the new response model.

This class introduces typed methods on a new public model, so it should opt into strict typing at the file boundary.

♻️ Suggested change
 <?php
+
+declare(strict_types=1);
 
 namespace Appwrite\Utopia\Response\Model;

As per coding guidelines, **/*.php: Use strict type declarations where applicable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformWeb.php` around lines 1 - 8, Add a
strict types declaration to the new response model file by inserting
declare(strict_types=1); immediately after the opening <?php tag in the file
containing the class PlatformWeb (the PlatformWeb class file that extends
PlatformBase), so the file opts into strict typing for its typed public methods.
app/init/models.php (1)

337-339: Please add one regression test around the split platform registrations.

These registrations are now the wiring that makes mixed platforms lists resolve to PlatformWeb vs PlatformApp. A small serialization/spec test with one web platform and one app platform would protect the new public contract from drifting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/init/models.php` around lines 337 - 339, Add a regression test that
asserts mixed platform entries deserialize/resolve to the correct concrete
models: ensure Response::setModel registrations for PlatformWeb, PlatformApp,
and PlatformList continue to split mixed "platforms" lists into PlatformWeb vs
PlatformApp instances; create a spec that serializes a payload with one web
platform and one app platform, runs the same parsing/resolution used by the
application, and asserts the resulting collection contains one PlatformWeb and
one PlatformApp (use the same factory/parse method your app uses to ensure the
public contract is exercised).
src/Appwrite/Utopia/Response/Model/PlatformApp.php (2)

1-9: Add declare(strict_types=1); here too.

This is another new typed model file, so it should follow the same strict-typing boundary as the rest of the PHP surface.

♻️ Suggested change
 <?php
+
+declare(strict_types=1);
 
 namespace Appwrite\Utopia\Response\Model;

As per coding guidelines, **/*.php: Use strict type declarations where applicable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php` around lines 1 - 9, This
PHP model file is missing the strict types declaration; add
declare(strict_types=1); as the first statement after the opening <?php tag in
the file that defines the PlatformApp class (class PlatformApp extends
PlatformBase) so the file follows the project's strict-typing guideline.

78-83: Fix the filter() PHPDoc.

The current block still says Get Collection, which no longer describes this method and omits the $document parameter.

♻️ Suggested change
-    /**
-     * Get Collection
-     *
-     * `@return` Document
-     */
+    /**
+     * Normalize app platform documents for the public API response.
+     *
+     * `@param` Document $document
+     *
+     * `@return` Document
+     */

As per coding guidelines, **/*.php: Include comprehensive PHPDoc comments.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php` around lines 78 - 83,
Update the PHPDoc for the method filter(Document $document): Document to
accurately describe its behavior (it filters/transforms a Document) and add the
missing `@param` annotation for $document with the Document type and a brief
description plus a clear `@return` Document description; locate the PHPDoc
immediately above the filter(Document $document): Document method and replace
the incorrect "Get Collection" summary with a concise description and the two
annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/init/models.php`:
- Around line 337-339: Add a regression test that asserts mixed platform entries
deserialize/resolve to the correct concrete models: ensure Response::setModel
registrations for PlatformWeb, PlatformApp, and PlatformList continue to split
mixed "platforms" lists into PlatformWeb vs PlatformApp instances; create a spec
that serializes a payload with one web platform and one app platform, runs the
same parsing/resolution used by the application, and asserts the resulting
collection contains one PlatformWeb and one PlatformApp (use the same
factory/parse method your app uses to ensure the public contract is exercised).

In `@src/Appwrite/Utopia/Response/Model/PlatformApp.php`:
- Around line 1-9: This PHP model file is missing the strict types declaration;
add declare(strict_types=1); as the first statement after the opening <?php tag
in the file that defines the PlatformApp class (class PlatformApp extends
PlatformBase) so the file follows the project's strict-typing guideline.
- Around line 78-83: Update the PHPDoc for the method filter(Document
$document): Document to accurately describe its behavior (it filters/transforms
a Document) and add the missing `@param` annotation for $document with the
Document type and a brief description plus a clear `@return` Document description;
locate the PHPDoc immediately above the filter(Document $document): Document
method and replace the incorrect "Get Collection" summary with a concise
description and the two annotations.

In `@src/Appwrite/Utopia/Response/Model/PlatformWeb.php`:
- Around line 1-8: Add a strict types declaration to the new response model file
by inserting declare(strict_types=1); immediately after the opening <?php tag in
the file containing the class PlatformWeb (the PlatformWeb class file that
extends PlatformBase), so the file opts into strict typing for its typed public
methods.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 60239fd6-c767-43d8-be4e-a476a88820c2

📥 Commits

Reviewing files that changed from the base of the PR and between 8ccf509 and e5841c4.

📒 Files selected for processing (6)
  • app/config/errors.php
  • app/init/models.php
  • src/Appwrite/Extend/Exception.php
  • src/Appwrite/Utopia/Response.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Utopia/Response/Model/PlatformWeb.php
✅ Files skipped from review due to trivial changes (1)
  • src/Appwrite/Extend/Exception.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Appwrite/Utopia/Response.php
  • app/config/errors.php

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (2)

3751-3925: ⚠️ Potential issue | 🟠 Major

Missing explicit compatibility assertion for newly introduced platform type mapping.

The new platform-type surface (including react-native-web) isn’t asserted here under 1.8.0 compatibility mode. Given src/Appwrite/Utopia/Response/Filters/V21.php (Line 11-20, Line 55-66) currently normalizes fields but does not transform type, this is a backward-compatibility gap in test coverage.

Please add create/get/update assertions for the new type in legacy response format to lock expected type values for 1.8 clients.

Also applies to: 3957-4100, 4110-4280


3754-4525: ⚠️ Potential issue | 🟠 Major

Default response contract coverage regressed to legacy-only path.

By forcing x-appwrite-response-format: 1.8.0 on all platform CRUD calls, these tests no longer exercise the default (current) platform response contract introduced in this PR. That leaves the new public platform API path unguarded in e2e.

Please keep these legacy assertions, but add at least one CRUD flow without the legacy header to validate the current response models as well.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/Services/Projects/ProjectsConsoleClientTest.php` around lines 3754
- 4525, The tests currently force the legacy response contract by always sending
the 'x-appwrite-response-format: 1.8.0' header for platform CRUD paths; keep
those legacy assertions but add at least one full CRUD flow that omits that
header so the default/current platform response contract is exercised. Locate
the platform create/get/update/delete sequences (e.g., calls via
$this->client->call in setupProjectWithPlatform() or the
testDeleteProjectPlatform / testGetProjectPlatform / testUpdateProjectPlatform
methods) and add a new platform lifecycle: POST (create) without
'x-appwrite-response-format', assert the new/current response fields, then GET,
PUT, and DELETE that platform also without the legacy header, asserting expected
status codes and the current response model at each step.
🧹 Nitpick comments (8)
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php (3)

27-30: Add return type declaration to getName() method.

The method lacks a return type declaration. For consistency with strict typing practices:

Proposed fix
-    public static function getName()
+    public static function getName(): string
     {
         return 'listProjectPlatforms';
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`
around lines 27 - 30, The getName() method in class XList currently lacks a
return type; update the method signature for getName() to declare a string
return type (i.e., ensure getName(): string) so it consistently enforces strict
typing and returns 'listProjectPlatforms' as before.

56-57: Parameter name mismatch: total vs $includeTotal.

The param is named 'total' (line 57) but the corresponding action method parameter is $includeTotal (line 70). While the framework may map by position, inconsistent naming reduces readability and maintainability. Consider aligning them:

Option A: Rename the action parameter to match
     public function action(
         array $queries,
-        bool $includeTotal,
+        bool $total,
         Document $project,
         Response $response,
         Database $dbForPlatform,
         Authorization $authorization,
     ) {

Then update the usage on line 110:

-            $total = $includeTotal ? $authorization->skip(fn () => $dbForPlatform->count('platforms', $filterQueries, APP_LIMIT_COUNT)) : 0;
+            $totalCount = $total ? $authorization->skip(fn () => $dbForPlatform->count('platforms', $filterQueries, APP_LIMIT_COUNT)) : 0;
Option B: Rename the param to match
-            ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
+            ->param('includeTotal', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`
around lines 56 - 57, The declared request parameter name 'total' in XList.php
is inconsistent with the action method parameter $includeTotal; choose one
naming approach and make them match to improve readability: either rename the
action method parameter $includeTotal to $total (in the XList action signature
and all uses, e.g., the place around line 70 and usage around line 110) or
rename the param declaration from 'total' to 'includeTotal' (in the ->param(...)
call that references Platforms::ALLOWED_ATTRIBUTES), ensuring both the param
name and the action method signature are identical and updating any call sites
or docstrings accordingly.

65-75: Consider adding return type and comprehensive PHPDoc.

The action method lacks a return type declaration, and the PHPDoc only documents the $queries parameter. For better documentation and type safety, consider expanding:

Proposed enhancement
     /**
      * `@param` array<string> $queries
+     * `@param` bool $includeTotal
+     * `@param` Document $project
+     * `@param` Response $response
+     * `@param` Database $dbForPlatform
+     * `@param` Authorization $authorization
+     * `@return` void
      */
     public function action(
         array $queries,
         bool $includeTotal,
         Document $project,
         Response $response,
         Database $dbForPlatform,
         Authorization $authorization,
-    ) {
+    ): void {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`
around lines 65 - 75, The action method in class XList (method name: action) is
missing a return type declaration and has incomplete PHPDoc (only $queries
documented); update the docblock to document all parameters (queries,
includeTotal, project, response, dbForPlatform, authorization) with proper types
(array<string>, bool, Document, Response, Database, Authorization) and add a
precise `@return` annotation for the actual return type, then add the
corresponding PHP return type declaration to the method signature to match the
`@return` (e.g., : Response or : array|Response|null as appropriate) so IDEs and
static analyzers can validate usage.
tests/e2e/Services/Projects/ProjectsBase.php (1)

154-252: Typos in variable names: "Fultter" should be "Flutter".

The variable names contain consistent typos throughout the file:

  • $platformFultteriOSId$platformFlutteriOSId
  • $platformFultterAndroidId$platformFlutterAndroidId
  • $platformFultterWebId$platformFlutterWebId

While this doesn't affect functionality, it reduces code readability. Consider fixing these in a follow-up since they exist throughout the file (including the cached array keys on lines 256-258).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/Services/Projects/ProjectsBase.php` around lines 154 - 252, The
variables for Flutter platforms contain typos—rename $platformFultteriOSId,
$platformFultterAndroidId, and $platformFultterWebId to $platformFlutteriOSId,
$platformFlutterAndroidId, and $platformFlutterWebId respectively, and update
every usage (including the cached array keys mentioned around the later block)
to use the corrected names so references like the POST response assignments and
any subsequent reads use the new identifiers consistently.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php (1)

1-27: Missing strict type declaration.

PSR-12 recommends using strict type declarations for PHP files. Consider adding declare(strict_types=1); after the opening PHP tag.

Additionally, the class extends Appwrite\Platform\Modules\Compute\Base (line 8) but this is a Project module endpoint. Verify this is the intended base class, as it may be more appropriate to extend a base class from the Project module for consistency.

🛠️ Suggested improvement
 <?php
+
+declare(strict_types=1);

 namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms\Web;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php`
around lines 1 - 27, Add a strict types declaration by inserting
declare(strict_types=1); immediately after the opening <?php tag in this file,
and verify the class inheritance: the Create class currently extends
Appwrite\Platform\Modules\Compute\Base (imported as Base) which looks incorrect
for a Project module endpoint — either change the use/import to the Project
module base (e.g., Appwrite\Platform\Modules\Project\Base) and update the class
extends accordingly, or confirm that Compute\Base is intentional and
remove/adjust the misleading import/comment; ensure any related use statements
(use Appwrite\Platform\Modules\Compute\Base) are updated to match the chosen
base.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (1)

3754-4525: Extract platform legacy headers to a helper to reduce drift.

The same legacy header block is repeated many times; a small helper will reduce copy/paste errors and make future response-format migrations safer.

Refactor sketch
+    private function platformHeaders(bool $legacy = true): array
+    {
+        return array_merge([
+            'content-type' => 'application/json',
+            'x-appwrite-project' => $this->getProject()['$id'],
+        ], $legacy ? [
+            'x-appwrite-response-format' => '1.8.0',
+        ] : [], $this->getHeaders());
+    }

Then replace repeated array_merge([...], $this->getHeaders()) blocks in platform tests with platformHeaders().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/Services/Projects/ProjectsConsoleClientTest.php` around lines 3754
- 4525, Extract the repeated legacy header array_merge([...],
$this->getHeaders()) into a helper method (e.g., platformHeaders()) in this test
class and replace each occurrence in platform-related tests (methods like
setupProjectWithPlatform(), setupProjectData(), testListProjectPlatform(),
testGetProjectPlatform(), testUpdateProjectPlatform(),
testDeleteProjectPlatform()) with a call to platformHeaders(); implement
platformHeaders() to accept an optional array of overrides (merge defaults like
'content-type','x-appwrite-project','x-appwrite-response-format' with
$this->getHeaders() and any passed overrides) so every client->call uses
platformHeaders() instead of duplicating the array_merge.
src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php (2)

1-2: Add strict type declaration.

Per coding guidelines, PHP files should use strict type declarations where applicable.

 <?php
+
+declare(strict_types=1);
 
 namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms\App;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`
around lines 1 - 2, This PHP file is missing a strict types declaration; add
declare(strict_types=1); immediately after the opening <?php tag in src Appwrite
Platform Modules Project Http Project Platforms App Create.php (the file
containing the Create class) so the Create class and any functions in this file
are evaluated under strict typing rules.

31-34: Add return type declaration.

The getName() method should have a return type hint for PSR-12 compliance.

-    public static function getName()
+    public static function getName(): string
     {
         return 'createProjectAppPlatform';
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`
around lines 31 - 34, The getName() method lacks a return type declaration;
update the public static function getName() in the Create class to declare and
return a string (add a ": string" return type) so it matches PSR-12 and
accurately types the returned value 'createProjectAppPlatform'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`:
- Around line 167-169: The Create action mutates $platform after persist by
calling $platform->setAttribute('hostname', '') when $isDeprecatedRequest is
false, causing a create response that differs from subsequent GETs (DB stores
hostname as null); remove the post-creation mutation
($platform->setAttribute('hostname', '')) and instead ensure hostname
normalization is handled consistently either by persisting an empty string at
write time or (preferred) converting null→'' in the response layer (e.g., in the
Platform response formatter / toArray / ProjectResponseModel) so create and read
responses match.

---

Outside diff comments:
In `@tests/e2e/Services/Projects/ProjectsConsoleClientTest.php`:
- Around line 3754-4525: The tests currently force the legacy response contract
by always sending the 'x-appwrite-response-format: 1.8.0' header for platform
CRUD paths; keep those legacy assertions but add at least one full CRUD flow
that omits that header so the default/current platform response contract is
exercised. Locate the platform create/get/update/delete sequences (e.g., calls
via $this->client->call in setupProjectWithPlatform() or the
testDeleteProjectPlatform / testGetProjectPlatform / testUpdateProjectPlatform
methods) and add a new platform lifecycle: POST (create) without
'x-appwrite-response-format', assert the new/current response fields, then GET,
PUT, and DELETE that platform also without the legacy header, asserting expected
status codes and the current response model at each step.

---

Nitpick comments:
In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php`:
- Around line 1-2: This PHP file is missing a strict types declaration; add
declare(strict_types=1); immediately after the opening <?php tag in src Appwrite
Platform Modules Project Http Project Platforms App Create.php (the file
containing the Create class) so the Create class and any functions in this file
are evaluated under strict typing rules.
- Around line 31-34: The getName() method lacks a return type declaration;
update the public static function getName() in the Create class to declare and
return a string (add a ": string" return type) so it matches PSR-12 and
accurately types the returned value 'createProjectAppPlatform'.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php`:
- Around line 1-27: Add a strict types declaration by inserting
declare(strict_types=1); immediately after the opening <?php tag in this file,
and verify the class inheritance: the Create class currently extends
Appwrite\Platform\Modules\Compute\Base (imported as Base) which looks incorrect
for a Project module endpoint — either change the use/import to the Project
module base (e.g., Appwrite\Platform\Modules\Project\Base) and update the class
extends accordingly, or confirm that Compute\Base is intentional and
remove/adjust the misleading import/comment; ensure any related use statements
(use Appwrite\Platform\Modules\Compute\Base) are updated to match the chosen
base.

In `@src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php`:
- Around line 27-30: The getName() method in class XList currently lacks a
return type; update the method signature for getName() to declare a string
return type (i.e., ensure getName(): string) so it consistently enforces strict
typing and returns 'listProjectPlatforms' as before.
- Around line 56-57: The declared request parameter name 'total' in XList.php is
inconsistent with the action method parameter $includeTotal; choose one naming
approach and make them match to improve readability: either rename the action
method parameter $includeTotal to $total (in the XList action signature and all
uses, e.g., the place around line 70 and usage around line 110) or rename the
param declaration from 'total' to 'includeTotal' (in the ->param(...) call that
references Platforms::ALLOWED_ATTRIBUTES), ensuring both the param name and the
action method signature are identical and updating any call sites or docstrings
accordingly.
- Around line 65-75: The action method in class XList (method name: action) is
missing a return type declaration and has incomplete PHPDoc (only $queries
documented); update the docblock to document all parameters (queries,
includeTotal, project, response, dbForPlatform, authorization) with proper types
(array<string>, bool, Document, Response, Database, Authorization) and add a
precise `@return` annotation for the actual return type, then add the
corresponding PHP return type declaration to the method signature to match the
`@return` (e.g., : Response or : array|Response|null as appropriate) so IDEs and
static analyzers can validate usage.

In `@tests/e2e/Services/Projects/ProjectsBase.php`:
- Around line 154-252: The variables for Flutter platforms contain typos—rename
$platformFultteriOSId, $platformFultterAndroidId, and $platformFultterWebId to
$platformFlutteriOSId, $platformFlutterAndroidId, and $platformFlutterWebId
respectively, and update every usage (including the cached array keys mentioned
around the later block) to use the corrected names so references like the POST
response assignments and any subsequent reads use the new identifiers
consistently.

In `@tests/e2e/Services/Projects/ProjectsConsoleClientTest.php`:
- Around line 3754-4525: Extract the repeated legacy header array_merge([...],
$this->getHeaders()) into a helper method (e.g., platformHeaders()) in this test
class and replace each occurrence in platform-related tests (methods like
setupProjectWithPlatform(), setupProjectData(), testListProjectPlatform(),
testGetProjectPlatform(), testUpdateProjectPlatform(),
testDeleteProjectPlatform()) with a call to platformHeaders(); implement
platformHeaders() to accept an optional array of overrides (merge defaults like
'content-type','x-appwrite-project','x-appwrite-response-format' with
$this->getHeaders() and any passed overrides) so every client->call uses
platformHeaders() instead of duplicating the array_merge.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c4c05b4-030e-46e9-ade1-5f4a4f8bdf9a

📥 Commits

Reviewing files that changed from the base of the PR and between e5841c4 and 038f4b5.

📒 Files selected for processing (13)
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Delete.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Web/Create.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php
  • src/Appwrite/SDK/Specification/Format.php
  • src/Appwrite/SDK/Specification/Format/OpenAPI3.php
  • src/Appwrite/SDK/Specification/Format/Swagger2.php
  • src/Appwrite/Utopia/Response/Filters/V21.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • tests/e2e/Services/Projects/ProjectsBase.php
  • tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/Appwrite/Utopia/Response/Filters/V21.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php
  • src/Appwrite/Utopia/Response/Model/PlatformApp.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Delete.php
  • src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/App/Update.php

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

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.

2 participants