Repository navigation
fix(projects): grant site screenshots to the team a project moves to - #15157
Conversation
Screenshots are files in the console screenshots bucket readable only by the team that owned the project when they were captured. Moving a project re-granted the project and its VCS records but not these files, so the new team could no longer preview any deployment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR grants screenshot file permissions to the destination team when a project's team is transferred, by scanning the project's site deployments and bulk-updating permissions on the
Reviewed commit: a5e27f3 |
🟢 Tier S · Ready to merge
Project team transfers now grant the destination team read access to existing site deployment screenshots in bounded batches. Screenshot captures also use the project’s current team when creating files, and an E2E test verifies screenshot permissions after a transfer. Latest changes: The new worker change reloads the project’s current team after screenshot capture so captures queued before a transfer create files with the updated team’s permission.
📂 Walkthrough · 3
✅ Fixed since the last review · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
There was a problem hiding this comment.
Adds a grantScreenshots step to the project team-transfer endpoint so the incoming team gains read access to site screenshot files, covered by a console e2e test.
Key findings
- 🟡 Screenshot batch can exceed
APP_DATABASE_QUERY_MAX_VALUES— Update.php:156
| if (\count($ids) >= APP_DATABASE_QUERY_MAX_VALUES) { | ||
| $dbForPlatform->updateDocuments('bucket_' . $bucket->getSequence(), $updates, [Query::equal('$id', $ids)]); | ||
| $ids = []; | ||
| } |
There was a problem hiding this comment.
🟡 bug · medium
Screenshot batch can exceed APP_DATABASE_QUERY_MAX_VALUES
In grantScreenshots, up to two IDs (screenshotLight, screenshotDark) are appended per deployment before the \count($ids) >= APP_DATABASE_QUERY_MAX_VALUES flush check runs (src/Appwrite/Platform/Modules/Projects/Http/Projects/Team/Update.php:156). A batch can reach 501 values against the 500-value cap, making Query::equal('$id', $ids) invalid. The team transfer then fails with a 500 after the project was already moved, leaving screenshots un-granted.
📋 Prompt for AI Agents
In src/Appwrite/Platform/Modules/Projects/Http/Projects/Team/Update.php, in grantScreenshots (around lines 144-164), restructure the batching so a flush happens whenever the pending ID count would exceed APP_DATABASE_QUERY_MAX_VALUES (500): collect the deployment's screenshotLight/screenshotDark IDs first, and if count($ids) plus the new IDs would exceed the limit, flush the current batch via $dbForPlatform->updateDocuments('bucket_' . $bucket->getSequence(), $updates, [Query::equal('$id', $ids)]) and reset $ids before appending, so Query::equal never receives more than 500 values.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The capture message carries the project as it was when the build queued it, so a capture that ran after a team change granted its files to the previous team. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
After
PATCH /v1/projects/:projectId/team, the new team gets 404 on every site deployment screenshot (GET /v1/storage/buckets/screenshots/files/<id>/preview?project=console).Root cause
The screenshots worker stores each capture in the console
screenshotsbucket withread("team:<teamId at capture time>"). The team update re-grants the project, installations, repositories and VCS comments, but not these files.Fix
After the move, read every site deployment's
screenshotLight/screenshotDarkfrom the project database and bulk-update those files toread("team:<new>"), in chunks ofAPP_DATABASE_QUERY_MAX_VALUES. Safe to repeat.The screenshots worker also reads the project's team when it files a capture, instead of the copy carried on the queued message, so a capture finishing after the move does not go to the old team.
Test
SitesConsoleClientTest::testSiteScreenshotsMoveWithProjectTeam(groupscreenshots): deploy a static site, wait for both screenshots, move the project to a new team, assert both files carryread("team:<new>"). Without the fix they keep the old team.Related: appwrite-labs/cloud#6673