Skip to content

Fix TablesDB webhook event matching and delivery - #13597

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/tablesdb-webhook-event-context
Sep 10, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/tablesdb-webhook-event-context

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Tracks DAT-2542.

Fix database event namespaces being lost between HTTP operations, subscription matching, and webhook queue payloads. TablesDB routes use databases.… event templates internally; Event::generateEvents() needs the database document to project them to tablesdb.… while retaining legacy aliases. Realtime already supplied that context, but webhook/function matching and publishing did not.

  • Pass database context through HTTP shutdown, bulk row writes, and transaction commit event matching.
  • Use that context when constructing webhook payloads and function event messages, so matching and worker-visible event names agree.
  • Set database context for database create/update/delete, which previously omitted it entirely.
  • Preserve existing TablesDB databases.…tables.…rows.… and collection/document aliases. Keep DocumentsDB and VectorsDB namespaces distinct.

No new routes or subscription syntax. Existing column/index identifiers and their deletion-as-update event labels are unchanged.

End-to-end verification

Built an isolated local stack from this checkout (PHP 8.5.10, PostgreSQL, Redis, combined worker, local request catcher). Created a console account, project, API key, database, table, and enabled webhook through real HTTP APIs. Row creation returned 201, update returned 200, and GET confirmed persisted data.

For each phase, stopped the worker and inspected utopia-queue.queue.v1-webhooks, then restarted it and polled the catcher. Only the subscription prefix changed; the webhook and destination stayed the same.

Subscription Before: queued / delivered After: queued / delivered
tablesdb.*.tables.*.rows.*.create + .update 0 / 0 2 / 2
databases.*.tables.*.rows.*.create + .update 2 / 2 2 / 2

Delivered requests received HTTP 200. Both successful and missing-delivery cases showed attempts: 0 and empty logs: those fields describe failures, not total deliveries.

Focused committed regressions:

  • One E2E test for row create/update delivery and payloads, with separate TablesDB and legacy webhook subscriptions (console and server-key access).
  • One data-driven unit test for database-context propagation into webhook and function messages, including the no-context fallback. Uses a generator provider as required by Rector.

Broader local verification also passed bulk writes, transaction commits, database/table lifecycle, and column/index operations on the same production fix. Those exploratory tests were removed from the final diff to keep the regression focused (test additions reduced from 178 to 89 lines).

Passing checks

Executed in the isolated stack using docker compose -f /tmp/plush-webhook-compose.json exec -T appwrite as the command prefix:

test tests/unit/Event/
  OK: 19 tests, 291 assertions

test tests/e2e/Services/Webhooks/ --filter='testTablesDBRows|testSecretRotationZeroDowntime|testCreateWebhookWithCustomSecret'
  OK: 6 tests, 139 assertions (console and server-key suites)

vendor/bin/rector process --dry-run --config tests/tools/rector.php
  PASS: full configured test scope; no changes required

vendor/bin/pint --test --config pint.json <10 changed PHP files>
  PASS

vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G --no-progress <10 changed PHP files>
  No errors

git diff --check
  PASS

Before the fix, the new publishing unit regression demonstrated the missing database prefixes. The original HTTP/Redis/catcher reproduction above independently confirmed the dropped webhook jobs.

Scope and limitations

  • This is backend/API verification; no UI screenshots are applicable.
  • No production data or settings were changed. The reported customer's deployed version and exact subscriptions still need confirmation.
  • Function message generation is unit-tested, but full deployed function-runtime execution was not tested. DocumentsDB/VectorsDB coverage here is unit-level, not service E2E.
  • The full repository test suite was not run.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no new actionable defect identified since the previous review.

Summary

  • Supplies database context when generating webhook and function event names.
  • Adds context to database lifecycle events and specialized bulk/transaction publishing paths.
  • Adds end-to-end coverage for ordinary TablesDB row webhook delivery and unit coverage for namespace projection.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into fix/tablesdb-we..."

Comment thread tests/unit/Event/EventTest.php Resolved
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/tablesdb-webhook-event-context (after).

Metric Before After Change
🚀 Requests/sec 257.9 261.29 ⚪ +1.3%
⏱️ Latency P50 68.73 ms 66.24 ms ⚪ -3.6%
⏱️ Latency P95 157.91 ms 156.99 ms ⚪ -0.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 66.24 156.99 16,017 261.29 -0.92
Account 129.21 239.26 843 14.02 -5.71
TablesDB 63.57 117.19 8,711 143.89 -2.32
Storage 62.6 138.52 4,215 71.89 +2.02
Functions 98.95 187.73 2,248 39.02 +1.23

Top API waits (after)

API request Max wait (ms)
functions.variables.create 465.35
account.name.update 424.56
storage.files.create 395.61
functions.create 344.71
storage.buckets.create 318.01

@ChiragAgg5k
ChiragAgg5k merged commit 9c2e1ef into main Sep 10, 2026
44 of 46 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/tablesdb-webhook-event-context branch September 10, 2026 10:52
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 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.

2 participants