Repository navigation
fix(avatars): expose photo update and delete in the console SDK - #14055
Conversation
`updatePhoto` and `deletePhoto` declared `auth: [SESSION, JWT]`, and the specs task derives SDK platforms from the auth types (SESSION -> client, JWT/KEY -> server, ADMIN -> console), so both routes were generated for the client SDK only. The console needs them for the account profile photo, the same way the account routes (`account.get`, `updateName`) declare ADMIN alongside SESSION and JWT. Add `AuthType::ADMIN` to both routes. No behavior change: the scope, abuse limits, and handlers are untouched; only the SDK/spec metadata gains the console platform. Co-Authored-By: Claude Fable 5.1 <[email protected]>
🔵 Tier A · Mergeable after minor fixes
Adds ADMIN authentication metadata to the profile-photo update and delete routes so both methods are included in console SDK generation, without changing their handlers or runtime scopes. Adds console-session e2e coverage for uploading, resolving, and deleting photos, plus unauthenticated rejection, and shares photo-test helpers with the custom-client suite. Latest changes: The newest commits move photo helpers into AvatarsBase and add console-session upload, retrieval, deletion, and unauthorized-request tests.
Fix with agent prompt### Issue 1
src/Appwrite/Platform/Modules/Avatars/Http/Photo/Update.php:76
**Add regression coverage for console SDK method inclusion**
Neither changed route has a regression test asserting its inclusion in the console spec; the existing Avatars console suite exercises GET, and the write test only checks API-key rejection. Please add an automated generated-spec assertion for both `updatePhoto` and `deletePhoto`, covering the SDK-visible contract required by AGENTS.md so this omission cannot silently return.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 5
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The write routes were only exercised with a custom project session and an API key. Add console-project coverage so the Console's own flow is tested: a console user uploads and deletes their photo with their console session, `current()` and a lookup by user ID from another console user's session both serve the uploaded photo (how organization member lists render), and a request without a session is refused. Move the photo helpers (`createPhotoUser`, `createImage`, `createNoiseImage`, `uploadPhoto`, `getPhoto`, `assertSamePhoto`) from `AvatarsCustomClientTest` into the shared `AvatarsBase` trait so both client scopes use the same code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… deletePhoto Cloud SDK preview built from appwrite-labs/cloud feat-assistant2-0@2e5b73d, whose server-ce includes appwrite#14055. bun.lock regenerated with bun 1.4 (CI's version). lint:sdk-pins fails on pkg.vc pins by design; swap in the published release before merging. Co-Authored-By: Claude Fable 5.1 <[email protected]>
What does this PR do?
avatars.updatePhoto(PUT /v1/avatars/photo) andavatars.deletePhoto(DELETE /v1/avatars/photo) declareauth: [AuthType::SESSION, AuthType::JWT]. The specs task derives each route's SDK platforms from its auth types (AuthType::getPlatform():SESSION→ client,JWT/KEY→ server,ADMIN→ console), so both routes are generated for the client SDK only. The console SDK (@appwrite.io/console) getsgetPhotobut neither write route, which blocks the Console from offering a profile photo upload on the account page.This adds
AuthType::ADMINto both routes, matching how the other "current user" session routes are declared (account.get,account.updateName:[ADMIN, SESSION, JWT]). NoKEY: an API key has no current user.Metadata only. Handlers,
avatars.writescope, events, audits, and abuse limits are untouched.avatars.writeis already in the console$memberand$adminsscope lists inapp/config/roles.php, so console sessions could call these routes before; they just had no generated method.It also adds e2e coverage for the console flow, which previously existed only for a custom project session (
AvatarsCustomClientTest) and for API keys (AvatarsCustomServerTest, 401).Test Plan
AvatarsConsoleClientTest(console project, console user session), mirroring the custom-project tests:testUpdatePhotoWithConsoleSession: upload with the console session, then the photo is served for the session user, foruserId=current(), and for the user's ID from another console user's session (how organization member lists render); the other user's own avatar stays on initials.testDeletePhotoWithConsoleSession: 204, falls back to initials, deleting again is a no-op.testUpdatePhotoUnauthorized:PUT/DELETEwithout a session on the console project → 401.createPhotoUser,createImage,createNoiseImage,uploadPhoto,getPhoto,assertSamePhoto) moved fromAvatarsCustomClientTestinto the sharedAvatarsBasetrait; the custom-project tests are unchanged in behavior.vendor/bin/pint --testandvendor/bin/phpstan analyse(level 4) on the changed route and test files: pass.vendor/bin/phpunit tests/unit/SDK: 28 pass; the 15 errors areClass "Swoole\Http\Response" not foundon a machine without the Swoole extension and are identical onmain.server-ceref that already includes feat: custom user avatar upload and delete #13949: the console preview'stypes/services/avatars.d.tsanddist/esm/sdk.jscontain onlygetPhoto, while the client preview from the same build hasgetPhoto,updatePhoto,deletePhoto. After merge, the next@appwrite.io/consolebuild should declareupdatePhoto(params: { file, onProgress? })anddeletePhoto(); I'll verify on the Cloud preview and pin it in the Console.Related PRs and Issues
getPhoto; the upload card needs this change.Checklist
🤖 Generated with Claude Code