fix: paginate mailbox retrieval beyond maxObjectsInGet - #906
Open
pirate wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incomplete mailbox hierarchy loading when a JMAP server caps Mailbox/get responses at maxObjectsInGet (e.g., Stalwart), by switching to a paginated Mailbox/query + result-referenced Mailbox/get approach that loads all mailbox ids and fetches them page-by-page.
Changes:
- Add a new
getRawMailboxes()helper that paginatesMailbox/queryand fetches each page via result-referencedMailbox/get, rejecting inconsistent page results. - Update
getMailboxes()andgetAllMailboxes()to use the new complete mailbox loader for both primary and delegated/shared accounts. - Add/adjust Vitest coverage to validate pagination edge cases (split parent/child across pages, server page clamping, exact page multiples, later-page failures, and shared-account id namespacing).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/jmap/client.ts | Implements mailbox pagination via Mailbox/query + result-reference Mailbox/get and routes mailbox loaders through it. |
| lib/tests/jmap-recipient-mailboxes.test.ts | Updates mocks/docs to allow mailbox loading via query+get. |
| lib/tests/jmap-mailbox-pagination.test.ts | Adds dedicated tests for pagination correctness and failure handling. |
| lib/tests/jmap-draft-lifecycle.test.ts | Updates request mocking to answer mailbox loading via query+get. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
pirate
marked this pull request as draft
August 25, 2026 09:36
pirate
force-pushed
the
fix/mailbox-pagination
branch
from
August 25, 2026 10:20
b442e9d to
d5e19a7
Compare
pirate
force-pushed
the
fix/mailbox-pagination
branch
5 times, most recently
from
August 25, 2026 22:06
ad5d69b to
1e4cc54
Compare
pirate
marked this pull request as ready for review
August 25, 2026 23:57
pirate
force-pushed
the
fix/mailbox-pagination
branch
from
August 28, 2026 03:12
1e4cc54 to
5558692
Compare
pirate
force-pushed
the
fix/mailbox-pagination
branch
from
August 28, 2026 03:19
5558692 to
d4cdbab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design
Paginate folder retrieval and ensure parent folders are sent to frontend before nested child folders.
Mailbox/queryreturns parent-first ID pages withsortAsTree, bounded by the server-advertisedmaxObjectsInGet.Mailbox/getthrough a result reference in the same JMAP request. Request count scales by page, never by folder.Capped object slice
Complete parent-first hierarchy
Validation