fix: omit pagination token when all shard cursors are null#720
Open
PirosB3 wants to merge 4 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PirosB3
commented
Nov 11, 2025
Asserts next_page_token is None when all shards have exhausted pagination, locking in the fix for the [null,null,...] cursor bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
src/network/http_server.rssrc/network/server.rs |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a cross-shard pagination bug where an “exhausted” cursor was still being returned as a serialized [null, null, ...] token, causing clients to paginate indefinitely and receive duplicate results.
Changes:
- Add
serialize_page_token_if_not_emptyhelper to omitnext_page_tokenwhen all shards are exhausted (all per-shard tokens areNone). - Apply the helper across several multi-shard paginated RPC responses.
- Update HTTP JSON pagination token behavior to omit
nextPageTokenwhen absent, and addnextPageTokensupport for events; add a regression test forget_casts_by_parent.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/network/server.rs |
Introduces and uses a helper to avoid emitting a pagination token when all shards are exhausted. |
src/network/server_tests.rs |
Adds a regression test ensuring get_casts_by_parent returns None next_page_token when drained. |
src/network/http_server.rs |
Ensures nextPageToken is omitted (not "") when absent; adds events nextPageToken field support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Rename `serialize_page_token_if_not_empty` to `serialize_page_token_if_any_shard_has_next` to describe the actual predicate (per Copilot review). - Add `test_get_events_returns_none_token_when_exhausted` to cover a second call site of the helper. - Add unit tests in `http_server` verifying that `map_proto_messages_response_to_json_paged_response` omits `nextPageToken` when the proto field is `None` and base64-encodes it when `Some(_)`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Fixes a pagination bug that occurs when
pageTokenisnullacross all shards. In that scenario the implementation serialized[null, null, ...]and returned it as the next page token, instead of omitting the cursor. Affects all multi-shard paginated endpoints:get_events,get_casts_by_parent,get_casts_by_mention,get_reactions_by_cast,get_reactions_by_target,get_links_by_target.Result: clients receive duplicate results and keep paginating in a loop.
The HTTP layer had related issues that are also fixed here:
EventsResponsewas missing thenextPageTokenfield entirely, so HTTP clients couldn't paginate events at all.map_proto_messages_response_to_json_paged_responsecoercedNoneintoSome("")instead of omitting the field.Tests: adds
test_get_casts_by_parent_returns_none_token_when_exhausted, which drains a query across two shards and assertsnext_page_tokenisNoneonce exhausted. Fails onmain, passes on this branch.