fix(events): check row and document actions against their own level by callmegautam · Pull Request #14742 · appwrite/appwrite · GitHub
Skip to content

fix(events): check row and document actions against their own level - #14742

Open
callmegautam wants to merge 2 commits into
appwrite:mainfrom
callmegautam:fix-14653-upsert-event-validation
Open

callmegautam wants to merge 2 commits into
appwrite:mainfrom
callmegautam:fix-14653-upsert-event-validation

Conversation

@callmegautam

Copy link
Copy Markdown

What does this PR do?

Fixes function and webhook subscriptions to row/document upsert events, which were rejected with 400 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] (the tables / collections level). create, update and delete passed only because that level has actions with the same names. upsert exists only under rows / 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

  • Added unit assertions in tests/unit/Event/Validator/EventValidatorTest.php:
    • valid: 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.*.upsert
    • invalid: tablesdb.*.tables.*.upsert (upsert is not a table action), tablesdb.*.tables.*.rows.*.unknown
  • Without the fix the test fails at the first upsert assertion. With the fix:
    • vendor/bin/phpunit tests/unit/Event passes (46 tests, 413 assertions)
    • pint --test passes on both files
    • phpstan analyse src/Appwrite/Event/Validator/Event.php reports no errors

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? (No API metadata changes.)

@hansi-codes

hansi-codes Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread src/Appwrite/Event/Validator/Event.php Outdated

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown
Contributor

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

This branch has not been deployed

No deployments
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.

🐛 Bug Report: Function and webhook events reject tablesdb.*.tables.*.rows.*.upsert ("Event is not valid")

1 participant