Skip to content

fix(compute): reject canceling another resource's deployment - #13104

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/deployment-status-ownership
Aug 5, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/deployment-status-ownership

Conversation

@cursor

@cursor cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds missing deployment ownership checks to Functions and Sites status-update (cancel) endpoints:

  • PATCH /v1/functions/:functionId/deployments/:deploymentId/status
  • PATCH /v1/sites/:siteId/deployments/:deploymentId/status

These endpoints previously only checked isEmpty(), so a caller with write access on one function/site could cancel a build belonging to another resource. Sibling Get/Delete/Download endpoints already reject this with DEPLOYMENT_NOT_FOUND when resourceId does not match.

Test Plan

  • Added e2e coverage:
    • FunctionsCustomServerTest::testCancelDeploymentRequiresOwnership
    • SitesCustomServerTest::testCancelDeploymentRequiresOwnership

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 5, 2026 03:37
Functions and Sites status-update (cancel) endpoints fetched a
deployment by ID without verifying it belonged to the function/site
in the URL path. A caller with write access on one resource could
cancel a build belonging to another.

Match Get/Delete/Download by rejecting with DEPLOYMENT_NOT_FOUND when
resourceId does not match.

Supersedes the stale #11868 approach with a rebased fix.

Co-authored-by: Chirag Aggarwal <[email protected]>
Add e2e regressions that attempt to cancel a deployment through a
function/site that does not own it and expect deployment_not_found.

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

greptile-apps Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR completes deployment ownership validation for the Functions and Sites cancellation endpoints.

  • Verifies both the owning resource ID and resource type before cancellation.
  • Prevents cross-resource and cross-type cancellation attempts from reaching the build lifecycle.
  • Adds end-to-end coverage for mismatched resource ownership.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported cross-resource-type cancellation path is closed because both endpoints now validate the deployment's resource type as well as its resource ID, and no blocking failure remains.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php Adds function deployment ownership and resource-type validation before cancellation; the earlier cross-type ID-collision issue is fixed.
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php Adds the corresponding site deployment ownership and resource-type validation before cancellation.
tests/e2e/Services/Functions/FunctionsCustomServerTest.php Adds coverage confirming a deployment cannot be canceled through another function.
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds coverage confirming a deployment cannot be canceled through another site.

Reviews (2): Last reviewed commit: "fix(compute): also require matching depl..." | Re-trigger Greptile

Function and site IDs are independent namespaces, so a resourceId-only
guard can still cancel a cross-type deployment when IDs collide. Reject
when resourceType is not functions/sites for the respective endpoint.

Co-authored-by: Chirag Aggarwal <[email protected]>
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

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

Metric Before After Change
🚀 Requests/sec 191.35 191.72 ⚪ +0.2%
⏱️ Latency P50 75.05 ms 73.97 ms ⚪ -1.4%
⏱️ Latency P95 261.99 ms 259.59 ms ⚪ -0.9%
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 73.97 259.59 12,027 191.72 -2.4
Account 142.25 352.94 633 10.5 -11.22
TablesDB 71.16 243.2 6,541 105.82 +0.98
Storage 66.12 236.14 3,165 52.85 -6.66
Functions 115.46 325.94 1,688 28.97 +16.41

Top API waits (after)

API request Max wait (ms)
functions.specifications.list 896.55
account.prefs.update 891.56
storage.files.create 829.12
functions.create 755.53
functions.variables.delete 743.68

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