Repository navigation
fix(users): resolve the cursor and count every membership in a user's memberships list - #14579
Conversation
… memberships list
GET /v1/users/{userId}/memberships passed a cursor query to the database with
the raw membership ID as its value, which the database refuses with "a cursor
must be a document", so any cursor answered 500. The action now resolves the
ID to its membership as the team memberships list does, and answers 400
general_cursor_not_found for an unknown one.
total was the number of memberships on the page, so a limit capped it; it is
now the count of every membership matching the filters.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR upgrades the users memberships list endpoint from client-side slicing to proper server-side cursor pagination, and aligns its response metadata with the real filtered result set. The e2e suite is extended to exercise the new pagination contract end to end.
Reviewed commit: c5a63a6 |
🟢 Tier S · Ready to merge
The users-memberships list now resolves cursor IDs to membership documents, returns the filtered membership count up to the configured cap, and maps null-order errors to the API error. The E2E coverage exercises cursor pagination, missing cursors, total counts, and the
📂 Walkthrough · 2
Merged |
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
Staging QA found two problems with
GET /v1/users/{userId}/memberships:cursorAfter/cursorBeforequery answered 500 with "Invalid cursor: a cursor must be a document, string given".totalwas the size of the returned page, so withlimit(1)it was always 1.Why
Users/Http/Users/Memberships/XList.phpnever resolved the cursor's membership ID into a document before callingfind(), so the database refused the raw string. It also settotaltocount($memberships)instead of counting the matching rows.Fix
The action now does what
Teams/Http/Memberships/XList.phpdoes:400 general_cursor_not_found.totalcomes fromcount()over the filter queries, capped atAPP_LIMIT_COUNT, and is still 0 withtotal=false.database_query_order_null.In the same file,
testListUserMembershipsswaps the deprecatedQuery::containson therolesarray forcontainsAny.Tests
The fix is in the HTTP action, so the E2E tests are the fixing-layer tests (
tests/e2e/Services/Users/UsersBase.php):UsersCustomServerTest)origin/maintestListUserMembershipsPaginatesWithACursor: cursorAfter + limit, cursorBefore, unknown cursorgeneral_unknowngeneral_cursor_not_foundfor the unknown IDtestListUserMembershipsTotalCountsEveryMembership: 3 memberships,limit(1)total1total3, and 0 withtotal=falseFull
UsersCustomServerTest(69 tests) andUsersConsoleClientTestpass locally.🤖 Generated with Claude Code