Skip to content

Fix effective SDK platform availability in OpenAPI specs - #9

Open
anurag6569201 wants to merge 1 commit into
qa/agent-appwrite-appwrite/pr-09-13502/basefrom
qa/agent-appwrite-appwrite/pr-09-13502/head
Open

anurag6569201 wants to merge 1 commit into
qa/agent-appwrite-appwrite/pr-09-13502/basefrom
qa/agent-appwrite-appwrite/pr-09-13502/head

Conversation

@anurag6569201

Copy link
Copy Markdown

What does this PR do?

Fixes x-appwrite.platforms to match actual SDK availability:

  • Removes server from OAuth2 session creation and usage events/gauges, where it is hidden.
  • Adds the missing server platform to presence update/upsert.
  • Adds platforms to individual method aliases so their availability is explicit.

This does not consolidate the three specs or change their filenames. Existing generated SDK output is unchanged.

Spec changes

Excerpts below omit unrelated fields.

OAuth2 session creation

GET /account/sessions/oauth2/{provider} already excludes server SDKs; its metadata now agrees:

 "x-appwrite": {
-  "platforms": ["console", "client", "server"]
+  "platforms": ["console", "client"]
 }

Usage events/gauges similarly change from ["console", "server"] to ["console"].

Presence update — server spec

 "operationId": "presencesUpdate",
 "x-appwrite": {
-  "platforms": ["client", "console"],
+  "platforms": ["client", "console", "server"],
   "methods": [
     {
       "name": "update",
       "namespace": "presences",
+      "platforms": ["server"],
       "required": ["presenceId", "userId"]
     }
   ]
 }

Presence update — client spec

 "operationId": "presencesUpdate",
 "x-appwrite": {
-  "platforms": ["client", "console"],
+  "platforms": ["client", "console", "server"],
   "methods": [
     {
       "name": "update",
       "namespace": "presences",
+      "platforms": ["client", "console"],
       "required": ["presenceId"]
     }
   ]
 }

The userId requirements are unchanged. The new metadata identifies the existing variants.

Validation

  • Regenerated client, server, and console specs; confirmed only the intended platform metadata changed.
  • Regenerated all 22 configured SDK targets: 14,899 files are byte-identical before and after.
  • Existing tests pass: 33 tests, 170 assertions. Formatting and targeted static checks pass.

Related to CLO-4377.

Source merge-base: 4176480f5d8bd88fc831575ed277bfb66abff894
Source head: bb45feda792f8e2631d6cd01d862c8526893af4c

@shipwright-agent

Copy link
Copy Markdown

✅ Shipwright · Approve

Recommendation: approve PR #9 · Tier T1
Checks: 0 total · 0 needing attention

Next step: ready to merge.

Findings (5)

  • HIGH The comment 'Null derives membership from auth; an explicit empty list stays empty' describes a subtle distinction that is not enforced by the type system. · src/Appwrite/SDK/Method.php:15
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new pre-resolution loop in Specs::action() calls setPlatforms() on every SDK Method before the per-platform loop, but getPlatforms() can still return an empty list when a Metho · src/Appwrite/Platform/Tasks/Specs.php:474
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH getPlatforms() derives platforms from getAuth() when $this->platforms is null, but AuthType::ORGANIZATION maps to null and is filtered out. · src/Appwrite/SDK/AuthType.php:19
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The OpenAPI3 parser now trusts Method::getPlatforms() to decide whether a route is emitted for a platform. · src/Appwrite/SDK/Specification/Format/OpenAPI3.php:247
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • LOW The new pre-resolution loop mutates SDK Method objects in place while iterating over $appRoutes. · src/Appwrite/Platform/Tasks/Specs.php:474
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Fireworks usage: 14,656 input · 663 output · 15,319 total tokens · $0.0037 · 13s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.


public static array $errors = [];

/** @var list<string>|null Null derives membership from auth; an explicit empty list stays empty. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The comment 'Null derives membership from auth; an explicit empty list stays empty' describes a subtle distinction that is not enforced by the type system.

Impact: The comment 'Null derives membership from auth; an explicit empty list stays empty' describes a subtle distinction that is not enforced by the type system. A future caller cannot tell from the API whether setPlatforms([]) means 'no platforms' or 'not yet resolved', and getPlatforms() silently falls back to auth-derived platforms only when the property is null. This implicit state machine is easy to misuse.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

throw new Exception('Failed to create specs directory: ' . $specsDir);
}

// Resolve full auth arrays through the active task (including subclass platforms).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The new pre-resolution loop in Specs::action() calls setPlatforms() on every SDK Method before the per-platform loop, but getPlatforms() can still return an empty list when a Metho

Impact: The new pre-resolution loop in Specs::action() calls setPlatforms() on every SDK Method before the per-platform loop, but getPlatforms() can still return an empty list when a Method has no namespace or is hidden. The per-platform loop then skips the route, silently dropping it from all generated specs. If any route relies on the old behavior where namespace/hide checks happened later or differently, that route disap…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

*/
case ORGANIZATION = APP_AUTH_TYPE_ORGANIZATION;

public function getPlatform(): ?string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

getPlatforms() derives platforms from getAuth() when $this->platforms is null, but AuthType::ORGANIZATION maps to null and is filtered out.

Impact: getPlatforms() derives platforms from getAuth() when $this->platforms is null, but AuthType::ORGANIZATION maps to null and is filtered out. A route secured only by ORGANIZATION will produce an empty platform list and be excluded from every SDK spec, even though the old switch also had no case for ORGANIZATION and would have produced an empty list. This is a latent behavior change risk if ORGANIZATION-only routes…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

continue;
}

$sdkPlatforms = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The OpenAPI3 parser now trusts Method::getPlatforms() to decide whether a route is emitted for a platform.

Impact: The OpenAPI3 parser now trusts Method::getPlatforms() to decide whether a route is emitted for a platform. Because getPlatforms() can be populated by the active specs producer via setPlatforms(), any producer that fails to call setPlatforms() or calls it with incorrect data will cause routes to be omitted from generated API specs. This is a spec-generation integrity risk rather than a runtime auth bypass, but it can…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

throw new Exception('Failed to create specs directory: ' . $specsDir);
}

// Resolve full auth arrays through the active task (including subclass platforms).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · LOW

The new pre-resolution loop mutates SDK Method objects in place while iterating over $appRoutes.

Impact: The new pre-resolution loop mutates SDK Method objects in place while iterating over $appRoutes. This side effect is not obvious from the surrounding code and makes the action() method harder to reason about because platform resolution now happens in two places: the pre-loop and getPlatforms() fallback.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

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