Repository navigation
fix(events): check row and document actions against their own level - #14742
Conversation
🟢 Tier S · Ready to merge
The event validator now checks row and document actions against their nested resource definitions, allowing valid Latest changes: The follow-up consolidates parent- and nested-resource action validation while retaining the non-empty parent ID check, and adds regression cases for empty table IDs.
Note @callmegautam does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. 📂 Walkthrough · 2
✅ Fixed since the last review · 1
Merged |
What does this PR do?
Fixes function and webhook subscriptions to row/document
upsertevents, which were rejected with400 general_argument_invalid("Event is not valid").For a 7-part pattern such as
tablesdb.*.tables.*.rows.*.upsert,Event::isValid()reads the action from$parts[6]but looked it up one level too high, in$events[$type][$subType](thetables/collectionslevel).create,updateanddeletepassed only because that level has actions with the same names.upsertexists only underrows/documents, so every row or document upsert subscription was refused.The validator now checks the action against
$events[$type][$subType][$subSubType]when the pattern has a sub-sub resource. 3-part and 5-part patterns are unchanged.Test Plan
tests/unit/Event/Validator/EventValidatorTest.php:tablesdb.*.tables.*.rows.*.upsert,tablesdb.books.tables.chapters.rows.*.upsert,databases.*.collections.*.documents.*.upsert,databases.books.tables.chapters.rows.prolog.upsert,documentsdb.*.collections.*.documents.*.upsert,vectorsdb.*.collections.*.documents.*.upserttablesdb.*.tables.*.upsert(upsert is not a table action),tablesdb.*.tables.*.rows.*.unknownvendor/bin/phpunit tests/unit/Eventpasses (46 tests, 413 assertions)pint --testpasses on both filesphpstan analyse src/Appwrite/Event/Validator/Event.phpreports no errorsRelated PRs and Issues
tablesdb.*.tables.*.rows.*.upsert("Event is not valid") #14653upsertto the events config)Checklist