Skip to content

fix(databases): build transaction delete events from the stored document - #14781

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/transaction-delete-event
Oct 22, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/transaction-delete-event

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What

  • The transaction operation validator now rejects a non-empty data on delete operations (applies to the legacy, TablesDB, DocumentsDB and VectorsDB operation routes, which share the validator).
  • On commit, a staged delete always loads the stored document before deleting it, and the delete event (realtime, webhooks, functions) is built from that document only. Previously staged data, when present, was used as the event payload instead.

Why

Delete events should describe the row that was actually removed. Staged deletes never need data, and the per-row delete route already stages data: [].

Tests

  • TransactionsBase::testCommitDeleteEventPayloadUsesStoredRecord (runs for legacy, TablesDB and DocumentsDB transaction suites): staging a delete with data returns 400; staging a delete without data and committing delivers a delete webhook whose payload matches the stored record (name and permissions).

E2E was not run locally (shared machine); relying on the CI e2e lanes. Pint, PHPStan and Rector pass for the touched files.

Related: appwrite-labs/cloud#6673

Staged delete operations carry no data of their own, so the event published on commit must reflect the row that was removed. Reject data on staged deletes and always load the stored document at commit.
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 3 nitpicks below.

🧹 Nitpicks (3) — 🟢 3 low
  • 🟢 Align delete-data rejection message with file convention (Operation.php:165) — The new rejection message does not follow the convention used by every other action-specific message in this validator, which interpolate the action name: "Key 'data' must be an array for {$action}" (src/Appwrite/Utopia/Database/Validator/Operation.php:175).
  • 🟢 Detached comment above bulk validations (Operation.php:170) — The comment // Bulk operation specific validations (src/Appwrite/Utopia/Database/Validator/Operation.php:170) is followed by a blank line instead of sitting directly above the bulk checks it describes, because the diff inserted the new delete check between them.
  • 🟢 Document the new delete-with-data rejection (Operation.php:165) — The Operation validator now rejects any delete operation whose data key is non-empty (src/Appwrite/Utopia/Database/Validator/Operation.php:165).

The change tightens the transaction operations contract: delete operations must no longer carry a data payload, and the transaction commit path now fills delete payloads from the stored document so event/webhook payloads carry real record fields. Three low-severity suggestions cover error-message consistency and documenting the new rejection on the operations endpoints.

Files Change
src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php Populates delete-operation data from the stored document instead of accepting client-supplied data.
src/Appwrite/Utopia/Database/Validator/Operation.php Rejects non-empty data on delete operations; minor message-style and comment-spacing nits.
tests/e2e/Services/Databases/Transactions/TransactionsBase.php Adds e2e coverage asserting a 400 for a delete operation carrying data.

Reviewed commit: 42b419e

@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The shared transaction operation validator now rejects delete operations with non-empty data. Transaction commits load the stored document for deletes and use it as the event payload, with E2E coverage for validation and webhook payloads.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php Builds delete operation event data from the document loaded during commit.
src/Appwrite/Utopia/Database/Validator/Operation.php Rejects non-empty data on delete operations across routes using the shared validator.
tests/e2e/Services/Databases/Transactions/TransactionsBase.php Adds E2E coverage for rejected delete data and the stored-record webhook payload.

Reviewed 42b419e · 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 22, 2026
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/transaction-delete-event (after).

Metric Before After Change
🚀 Requests/sec 217.93 225.72 ⚪ +3.6%
⏱️ Latency P50 77.3 ms 77.17 ms ⚪ -0.2%
⏱️ Latency P95 195.36 ms 174.58 ms 🟢 -10.6%
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 77.17 174.58 13,965 225.72 -20.78
Account 139.11 256.23 735 12.18 -52.25
TablesDB 76.1 141.51 7,595 124.71 +6.07
Storage 67.76 160.98 3,675 62.39 -9.24
Functions 106.94 199.49 1,960 33.95 -63.97

Top API waits (after)

API request Max wait (ms)
storage.buckets.create 454.32
account.name.update 407.06
tablesdb.rows.list 358.08
account.prefs.update 326.49
functions.create 324.3

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • 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 merged commit fadc04d into main Oct 22, 2026
69 checks passed
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…e-event

fix(databases): build transaction delete events from the stored document

(cherry picked from commit fadc04d)
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