Skip to content

fix(databases): emit surface-correct ids in committed transaction events - #13535

Merged
HarshMN2345 merged 2 commits into
mainfrom
fix/transaction-row-event-payload-ids
Sep 8, 2026
Merged

HarshMN2345 merged 2 commits into
mainfrom
fix/transaction-row-event-payload-ids

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Related to #12418.

What does this PR do?

Adds $databaseId and the appropriate $tableId or $collectionId to document and row events emitted when committing a transaction. The handler previously omitted the database ID and added both container keys.

The identifiers come from the database and collection resolved for each operation, matching normal document processing. This fixes the transaction path; it does not establish that the ordinary-create scenario in #12418 is resolved.

Test Plan

testCommitEventPayloadCarriesSurfaceIds stages and commits a record through the API, then uses getLastRequestForProject() with the unique record ID to find its webhook. It checks the database ID, the correct container ID and absence of the opposite container key.

The test uses the existing shared transaction suite. Pint and PHP syntax checks passed; the updated E2E runs in CI.

The commit handler is the only place that builds a row or document event
payload by hand instead of going through processDocument(). It never added the
synthetic $databaseId, which does not exist on a stored document, and wrote
both $tableId and $collectionId unconditionally.

So a function or webhook triggered by a committed transaction received a row
without $databaseId and carrying the legacy $collectionId, contradicting the
Row model. All four surfaces were affected, since the TablesDB, DocumentsDB and
VectorsDB transaction actions extend this one.

Add $databaseId and derive the container key from the group id already
resolved in the same loop, matching processDocument().
@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects committed transaction event payloads so they expose identifiers appropriate to the originating database API surface.

  • Adds the synthetic $databaseId to transaction-commit event payloads.
  • Emits only the applicable $tableId or $collectionId.
  • Adds shared end-to-end coverage that selects the transaction’s project-specific webhook delivery and validates its payload.

Confidence Score: 5/5

The PR appears safe to merge; no actionable regressions or outstanding rule violations were identified.

The transaction commit path now supplies the database identifier and exactly one surface-specific container identifier, while the shared test verifies the resulting project webhook payload across the supported API families.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php Aligns manually constructed commit-event payloads with the API family’s database and container identifier contract.
tests/e2e/Services/Databases/Transactions/TransactionsBase.php Adds shared cross-surface webhook assertions and scopes delivery lookup to the active project.

Reviews (2): Last reviewed commit: "test(databases): use project webhook pol..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/transaction-row-event-payload-ids (after).

Metric Before After Change
🚀 Requests/sec 421.8 430.12 ⚪ +2%
⏱️ Latency P50 40.73 ms 40.25 ms ⚪ -1.2%
⏱️ Latency P95 98.93 ms 94.64 ms ⚪ -4.3%
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 40.25 94.64 26,277 430.12 -4.29
Account 81.21 143.25 1,383 22.98 -8.88
TablesDB 38.7 69.96 14,291 235.41 -0.99
Storage 37.44 83.41 6,915 115.92 -2.36
Functions 63.9 114.58 3,688 62.46 -3.79

Top API waits (after)

API request Max wait (ms)
account.name.update 280.57
functions.variables.update 238.44
storage.files.create 237.27
tablesdb.rows.create 210.1
functions.delete 191.44

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