Skip to content

test(storage): deleting a bucket keeps buckets sharing its ID prefix - #14703

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/delete-bucket-prefix
Oct 20, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/delete-bucket-prefix

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Pins that deleting a bucket keeps buckets whose ID starts with the same characters (X and X2).

On S3, deletePath() used to list by the raw prefix, so deletePath('img') also matched img2/…. The storage package fixed that in 740f0ee: the S3 deletePath now always deletes <path>/. Nothing covered the worker's deleteBucket against it.

Checked against MinIO with packages/storage on main:

deletePath('img'):  img/file.txt deleted, img2/file.txt kept
deletePath('img/'): img/file.txt deleted, img2/file.txt kept
Lane testDeleteBucketKeepsBucketsSharingItsPrefix
S3 Storage pass
Local pass

Related: appwrite-labs/cloud#6628

On S3, deleting bucket X lists and deletes every key under the raw
prefix X, so the files of bucket X2 go with it.
@luxor-code-review

luxor-code-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Prefix-collision test leaks the kept bucket (StorageCustomServerTest.php:645) — testDeleteBucketKeepsBucketsSharingItsPrefix deletes $deletedId and asserts $keptId's file survives, but never cleans up $keptId or its uploaded file (tests/e2e/Services/Storage/StorageCustomServerTest.php:645-649), unlike the neighboring testDeleteBucket which removes what it creates.

This PR adds one e2e test to the Storage custom-server suite covering prefix-collision semantics of bucket deletion: it creates two buckets whose IDs share a prefix, uploads a file to each, deletes the prefix bucket, and asserts the surviving bucket's file remains downloadable while the deleted bucket's files disappear via assertEventually.

Files Change
tests/e2e/Services/Storage/StorageCustomServerTest.php Adds testDeleteBucketKeepsBucketsSharingItsPrefix verifying only prefix-matched buckets are deleted; minor spacing/formatting tweak in a neighboring test.

Reviewed commit: 1425d3e

@ghost

ghost commented Oct 20, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Checks the other bucket's files remain available. The test also verifies the deleted bucket's files are eventually removed.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
tests/e2e/Services/Storage/StorageCustomServerTest.php Adds an end-to-end test for bucket deletion when bucket IDs share a prefix.
🔇 Filtered out · 1

Findings Hansi considered but did not post.

Finding Why
The S3 prefix deletion is still unfixed Verifier: Already handled by the locally autoloaded storage library (composer.json:69). S3::deletePath() at packages/storage/src/Device/S3.php:726–730 converts the bucket ID to a directory using directory(), which explicitly returns a trailing slash at line 840. deletePrefix() passes that directory through prefix(), which preserves the slash (lines 165–182), and listBucket() uses it as the S3 prefix (lines 615–620). Thus deleting ID abc lists only .../abc/, not .../abc2/. AWS inherits this implementation. The raw ID at the worker call site is therefore safe, and the new assertion covers behavior already fixed in the library.

Reviewed 1425d3e · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k ChiragAgg5k changed the title fix(storage): deleting a bucket deletes buckets sharing its ID prefix test(storage): deleting a bucket keeps buckets sharing its ID prefix Oct 20, 2026
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/delete-bucket-prefix (after).

Metric Before After Change
🚀 Requests/sec 198.7 197.62 ⚪ -0.5%
⏱️ Latency P50 87.61 ms 88 ms ⚪ +0.4%
⏱️ Latency P95 204.57 ms 204.88 ms ⚪ +0.2%
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 88 204.88 12,540 197.62 +0.31
Account 169.7 319.87 660 11.08 +15.81
TablesDB 85.35 158.77 6,820 110.3 -9.4
Storage 80.84 180.23 3,300 54.86 -0.89
Functions 122.36 239.25 1,760 29.96 -12.11

Top API waits (after)

API request Max wait (ms)
account.name.update 538.17
account.prefs.update 428.89
functions.variables.update 421.31
storage.buckets.create 387.73
functions.variables.create 384.32

@ChiragAgg5k
ChiragAgg5k merged commit eaf2f3c into main Oct 20, 2026
33 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/delete-bucket-prefix branch October 20, 2026 15:55
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
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