Repository navigation
fix(databases): legacy cursor pages, unknown legacy methods and relationship ordering - #14543
Conversation
Two pre-1.8 request filters broke under utopia-php/database 8.x:
- V20 read the select queries through Query::groupByType, which now
insists a cursor is a resolved document. At request-filter time the
cursor is still the id the action resolves later, so every cursor
page of listDocuments from a pre-1.8 SDK answered 500. Read the
selects with getByType, which does not inspect the cursor.
- V17 built a Query from the method name, and the enum-backed
constructor throws a ValueError for an unknown method, leaking
"is not a valid backing value for enum Utopia\Query\Method" to the
client. Keep an unknown method as {"method": name} so the endpoint
rejects it with "Invalid query method", as it did before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A one-to-many parent, a many-to-one child and either side of a many-to-many keep their related ids on the other collection or in a junction table, so the collection has nothing to sort on. The library's order validator accepts every relationship key, the engine then fails on the unknown column, and 8.x surfaces that as NotFound, which the list action answered as a 404 for the whole collection. Validate the order queries against the collection's relationship columns first so the request is a 400 general_query_invalid naming the attribute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The branches list read limit and offset through Query::groupByType, which in utopia-php/database 8.x throws when the cursor is not a document. A branch cursor is a branch name, so every cursorAfter or cursorBefore page failed. Read limit and offset with getByType instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟠 1 high 💬 Inline comments (1)
The change introduces a new
Reviewed commit: 5f62105 |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
There was a problem hiding this comment.
This PR adds a query validator rejecting order-by on columnless relationship attributes for document listings, refactors limit/offset/cursor extraction in VCS branch listing and legacy request filters, and expands unit and e2e coverage.
Key findings
- 🟠 Branch cursor test conflicts with
BranchCursorstring contract — VCSGiteaConsoleClientTest.php:722
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
SDKs send a branch cursor as the plain branch name. Spell that payload out instead of serialising a Document, so the test reads as the request real clients make and does not lean on how the library serialises a document cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🟢 Tier S · Ready to merge
This pull request preserves legacy cursor query handling, sends unknown legacy methods through normal endpoint validation, and rejects ordering by relationship attributes without local columns. It also fixes branch-list pagination and expands unit and E2E coverage across the affected request formats and endpoints, with the latest test update waiting for newly created branches to appear before testing cursor pages. Latest changes: The newest commit makes the Gitea branch pagination E2E test poll until all three branches are visible before proceeding with cursor assertions.
📂 Walkthrough · 11
Reviewed the commits since |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gitea answers 201 for a new branch before its branch list includes it, so the first unfiltered list could see only main on a slow runner (PostgreSQL dedicated VCSGitea lane got 1 branch, expected 3). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Release blocker for #11649, found by staging QA of appwrite-labs/cloud#5410.
What
Three regressions in the utopia-php/database 8.x migration that main's E2E assertions catch on staging, plus a fourth with the same root cause found while auditing.
listDocumentsreturns 500 for every pre-1.8 SDK. The V20 request filter read select queries throughQuery::groupByType. In 8.x that throwsInvalid cursor: a cursor must be a document, string given, because at request-filter time the cursor is still the ID the action resolves later. The filter now reads selects withQuery::getByType($parsed, [Method::Select]), which leaves the cursor alone. This affects formats 1.5 to 1.7 (JSON syntax) and 1.4 (string syntax).bogus("title","x")with format 1.4.0 returned"bogus" is not a valid backing value for enum Utopia\Query\Method. V17 now keeps an unknown method as{"method":"bogus"}, so the endpoint rejects it withInvalid query method: bogusandgeneral_query_invalid, the same path as before 8.x.orderAsc("starringActors")on a one-to-many parent, a many-to-one child or either side of a many-to-many. The library's order validator accepts every relationship key, and the engine fails on the unknown column. 8.x maps that toNotFound, which the list action read as a missing collection or table. A newAppwrite\Utopia\Database\Validator\Query\Orderchecks the order queries against the collection's columnless relationships before anything runs, so the request now gets a 400general_query_invalidthat names the attribute. Main returned 500 here.Query::groupByTypewith a branch-name cursor and hit the same throw. It now reads limit and offset withgetByType.Audit
I checked every
groupByTypecaller insrc/andapp/:Documents/Getcatches theQueryExceptionand returns 400. A cursor on a get request is invalid anyway.TransactionStateruns after cursor resolution.Overlap
#14538 (
qfix-errors-blockers) changes how the list action maps aNotFoundcaused by an unknown column. This PR only adds the validator, which runs before that path, so the two are independent. They merge cleanly in either order (checked withgit merge-tree).Tests
V20Test: cursorAfter and cursorBefore IDs pass through, both with and without an explicit select.V17Test: an unknown method is kept for endpoint validation, and a dotted method is still rejected.OrderTest: covers every relationship type and side, plus plain, internal and unknown attributes.LegacyCustomServerTest: cursor pages for formats 1.7.0 and 1.5.0 (JSON) and 1.4.0 (string syntax), cursorBefore, and the unknown-method message.DatabasesBase:orderAscandorderDesconstarringActorsreturn 400 (Legacy and TablesDB).VCSGiteaConsoleClientTest: branch cursorAfter and cursorBefore pages.Invalid query: Invalid cursor: a cursor must be a document, string given. The new V17 case fails with"bogus" is not a valid backing value for enum Utopia\Query\Method.🤖 Generated with Claude Code