Repository navigation
fix(databases): use the database 8 relationship type in realtime relationship payloads - #14542
Conversation
…tionship payloads #14349 filtered relationship attributes out of create and transaction commit event payloads by comparing against Database::VAR_RELATIONSHIP. utopia-php/database 8 removed the VAR_* constants in favour of the ColumnType enum, so every document create, bulk event trigger and transaction commit fataled with an undefined constant and returned 500, and PHPStan reported three classConstant.notFound errors. Compare against ColumnType::Relationship->value, the idiom the rest of the module already uses. Stored _metadata attributes, Appwrite attribute documents and the Collection returned by getCollection() all carry the type as the string 'relationship' (Attribute::storedType), so the filter matches in every path that reaches it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR replaces hardcoded relationship-type string comparisons with the
Reviewed commit: abb2f10 |
🟢 Tier S · Ready to merge
Realtime relationship detection for bulk and single-document create payloads, and transaction commit payloads, now uses
📂 Walkthrough · 3
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What broke
mainhas been red since a10d3fd, the merge of #14349 (relationship attributes left out of create and transaction commit event payloads). That PR compares attribute types againstDatabase::VAR_RELATIONSHIP. The lockedutopia-php/database8.1.4 no longer defines that constant: the query-lib migration (#11649) replaced theVAR_*constants with theUtopia\Query\Schema\ColumnTypeenum. The last greenmainis f50c5bd (run 38699067303).Every
mainCI run after that has failed: a10d3fd, ca35312, 5204588, cdfd6a6 and d8c624f. On d8c624f (run 38712290555):classConstant.notFoundthree times, forUtopia\Database\Database::VAR_RELATIONSHIPatCollections/Documents/Action.php:511(triggerBulk, bulk create/update/upsert/delete events)Collections/Documents/Create.php:494(single create)Transactions/Update.php:536(transaction commit)Undefined constant Utopia\Database\Database::VAR_RELATIONSHIPfatals across those jobs (248 in GraphQL alone). The tests see these as 500s on document create, bulk writes andPATCH /databases/transactions/{id}commits. A commit 500 reportsTransactions/Update.phpline 536. Webhook deliveries for row creates go missing for the same reason.Fix
Compare against
ColumnType::Relationship->value. This is how the rest of the Databases module already checks for relationship attributes, for exampleDocuments/Update.php,Bulk/Delete.php,Attribute/Increment.php, andDocuments/Action.php:234in the same class.The comparison holds in every path that reaches it:
typeis the string'relationship'.getCollection()returns aUtopia\Database\Collection. Its constructor normalises typedAttributeobjects, stored documents and raw arrays into documents whosetypecomes fromAttribute::storedType(ColumnType::Relationship), which is'relationship'. A local probe built aCollectionfrom all three shapes and ran both filter idioms on it. Each one picked out exactly the relationship keys.No other constants were removed. A token-based scan of
src,app,bin,packagesandtestschecked everyUtopia\*andAppwrite\*class constant reference. It found no other undefined constant; the scan does flag the three original references when run on the unfixed files. A full PHPStan run over the project is clean.Verification
vendor/bin/phpstan analyse -c phpstan.neon(full project):[OK] No errors. On the unfixed files it reports the threeclassConstant.notFounderrors above.--test) on the changed files: passed.composer refactor:check(Rector dry-run overtests/) and Rector on the changed files: no changes.tests/unit/Event,tests/unit/Databasesandtests/unit/Platform/Modules/Databases: 86 tests, all passing.RealtimeCustomClientTest::testCreateRelationshipPayloadAlignsWithUpdateand::testTransactionCommitRelationshipPayloadAlignsWithUpdatefrom Omit relationship attributes from create and transaction commit event payloads #14349. Both go through the fixed lines, and they return 500 without this change.Unblocks
The query-lib release-blocker PRs #14535, #14536, #14537 and #14538 inherit this red from
main. They can go green once this merges.🤖 Generated with Claude Code