Repository navigation
fix(events): generate the attribute event before the action event - #13527
Conversation
`generateEvents()` appended the attribute-qualified pattern after the plain action pattern for top-level resources, so `users.[userId].update.name` generated `users.<id>.update` first. Consumers that report a single name read `events[0]`, so a function triggered by a name change received `APPWRITE_FUNCTION_EVENT=users.<id>.update` with the attribute dropped. Sub-resource patterns already emitted the most specific event first; move the attribute pattern into the same position for top-level resources so `events[0]` is always the concrete event that happened. This also stops the block emitting `teams.<id>.update.status` alongside a membership status update -- that event is not in the events config and the event validator rejects it, so nothing can subscribe to it.
55ccaa2 to
58c2928
Compare
Greptile SummaryThis PR corrects event generation ordering so top-level attribute-qualified events are emitted before their broader action events and prevents nested-resource attributes from producing invalid parent aliases.
Confidence Score: 5/5The PR appears safe to merge; the new ordering matches first-event consumer semantics without removing valid subscription patterns. The implementation preserves concrete and wildcard delivery patterns while making the complete event name first, and the only removed nested alias is not part of the configured event contract. Important Files Changed
Reviews (1): Last reviewed commit: "fix(events): generate the attribute even..." | Re-trigger Greptile |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Event::generateEvents()built its pattern list with the attribute-qualified pattern after the plain action pattern for top-level resources, so forusers.[userId].update.namethe generated list started with the less specific event:Consumers that have to report a single name read
events[0]— the functions worker publishes it asx-appwrite-event/APPWRITE_FUNCTION_EVENT(Workers/Functions.php:190), andRealtime::toTailMetadata()derives its metadata from it. A function triggered by a name change therefore sawAPPWRITE_FUNCTION_EVENT=users.<id>.update, with the.namesilently dropped. Same for.email,.phone,.password,.status,.prefs,.labels,.mfa,.verificationandteams.*.update.prefs.Sub-resource patterns already emitted the most specific event first (
users.<id>.sessions.<id>.deleteisevents[0]), andtestWildcardDeduplicationPreservesDeliveryOrderalready pins that invariant for the database family. This only fixes the one branch that broke it: the attribute pattern moves into theelsebranch, ahead of the action pattern.That trailing
if ($attribute)also applied to sub-resource patterns, so a membership status update was emittingteams.<id>.update.statusandteams.*.update.statuson top of the real events. Neither is inapp/config/events.php, andAppwrite\Event\Validator\Eventrejects them, so no webhook or function could ever have subscribed to them — they are now gone (16 events → 14).Webhooks are unaffected: they already send the full list in
X-Appwrite-Webhook-Events.Test Plan
New regression test
EventTest::testGenerateEventsOrderpins the full ordering for the reported pattern and asserts the sub-resource attribute case.Before (on
main):After:
Existing expectations are unchanged — event counts (4 / 6 / 10 / 42), the mirror-event tests, and
testWildcardDeduplicationPreservesDeliveryOrderall still pass, as does the full unit suite (1164 tests).Related PRs and Issues
Checklist