Skip to content

fix(deployments): require ownership on chunked upload resume - #13117

Closed
cursor[bot] wants to merge 9 commits into
mainfrom
fix/deployment-upload-resume-ownership
Closed

cursor[bot] wants to merge 9 commits into
mainfrom
fix/deployment-upload-resume-ownership

Conversation

@cursor

@cursor cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

POST .../deployments with x-appwrite-id loads an existing deployment to resume a chunked upload (or short-circuit when already complete) without checking that it belongs to the function/site in the URL. A caller could pass another resource's deployment ID and receive its completed deployment or continue mutating its upload state.

Adds resourceId + resourceType guards in both Functions and Sites Deployments/Create (both lock callbacks), matching Get/Delete/Status/Duplicate. Includes testCreateDeploymentResumeRequiresOwnership.

Test Plan

  • E2E: resume under foreign functionId with x-appwrite-id → 404 deployment_not_found
  • CI Functions / Sites e2e

Related PRs and Issues

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?
Open in Web View Automation 

cursoragent and others added 2 commits August 6, 2026 03:39
When createDeployment is resumed via x-appwrite-id, reject existing
deployments that belong to another function/site or resource type
instead of returning or mutating them. Adds a Functions e2e check.

Co-authored-by: Chirag Aggarwal <[email protected]>
@cursor
cursor Bot requested a review from ChiragAgg5k August 6, 2026 03:39
@cursor
cursor Bot marked this pull request as ready for review August 6, 2026 03:39
@greptile-apps

greptile-apps Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents chunked deployment resumes and completed-upload short-circuits from crossing Function or Site ownership boundaries.

  • Validates both the deployment resource ID and resource type in each resume lock callback.
  • Adds Functions and Sites regression coverage using foreign deployment IDs with chunked-upload headers.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php Adds ownership validation before both existing-deployment resume paths, preventing cross-function access and mutation.
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php Adds equivalent ownership validation for both Site deployment resume paths.
tests/e2e/Services/Functions/FunctionsCustomServerTest.php Covers a foreign Function deployment ID through the chunked-upload resume path and expects deployment_not_found.
tests/e2e/Services/Sites/SitesCustomServerTest.php Correctly exercises the Site ownership guard with content-range and a completed deployment owned by another Site.

Reviews (6): Last reviewed commit: "Merge branch 'main' into fix/deployment-..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/deployment-upload-resume-ownership (after).

Metric Before After Change
🚀 Requests/sec 171.86 169.52 ⚪ -1.4%
⏱️ Latency P50 82.2 ms 85.19 ms ⚪ +3.6%
⏱️ Latency P95 292.9 ms 292.71 ms ⚪ -0.1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.19 292.71 10,830 169.52 -0.19
Account 161.94 392.89 570 9.47 -24.1
TablesDB 81.76 272.62 5,890 93.73 +4.29
Storage 75.26 261.57 2,850 47.26 -4.14
Functions 125.8 341.46 1,520 25.62 -22.81

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.create 1,246.16
tablesdb.rows.decrement 1,102.83
storage.files.create 808.43
functions.delete 784.69
functions.variables.delete 748.38

cursoragent and others added 4 commits August 6, 2026 03:52
x-appwrite-id is only applied when content-range is present; without it
the handlers mint a fresh deployment ID and skip the ownership guard.

Co-authored-by: Chirag Aggarwal <[email protected]>
ChiragAgg5k and others added 2 commits August 6, 2026 15:00
Keep both ownership e2e tests: duplicate deployment from main and
upload resume from this branch.

Co-authored-by: Cursor <[email protected]>
Keep the partial-resume ownership test landed via #13118.

Co-authored-by: Cursor <[email protected]>
@ChiragAgg5k ChiragAgg5k closed this Aug 6, 2026
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.

3 participants