Fix pagination token parsing error#8424
Conversation
Co-authored-by: eric.okuma <eric.okuma@rilldata.com>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| executedOn = *partition.ExecutedOn | ||
| } | ||
| return pagination.MarshalPageToken(executedOn, partition.Key) | ||
| } |
There was a problem hiding this comment.
Bug: Pagination fails for pending partitions with NULL ExecutedOn
When paginating through pending partitions (where ExecutedOn is NULL), modelPartitionPageToken encodes a zero time. On the next page request, this zero time is passed as BeforeExecutedOn, causing the SQL query to include both executed_on IS NULL (from WherePending) and comparison conditions like executed_on < zero_time. Since SQL NULL values don't compare equal to or less than any actual value, these conditions are mutually exclusive and the query returns zero results. The pagination effectively breaks on the second page for pending partitions.
Fixes APP-613
The
rill project partitionscommand's--page-tokenfailed because theExecutedOntimestamp was not correctly marshaled into the pagination token, leading to aTime.UnmarshalJSONerror.This PR updates the pagination token generation to correctly encode the
ExecutedOntimestamp (with a zero-time fallback for nil values) alongside the partition key. A new helper functionmodelPartitionPageTokenencapsulates this logic, and dedicated unit tests ensure proper token creation and decoding for both present and nilExecutedOnvalues.Checklist:
Linear Issue: APP-613
Note
Fixes page token generation for model partitions by encoding ExecutedOn with key, refines pagination limit usage, and adds unit tests.
NextPageTokenusing newmodelPartitionPageToken, encodingExecutedOn(with zero-time fallback) and partitionKeyviapagination.MarshalPageToken.pageLimitand update next-page condition tolen(partitions) == pageLimit && > 0.controller_pagination_test.gowith cases for present and nilExecutedOn, verifying token marshal/unmarshal of time and key.Written by Cursor Bugbot for commit f1b581d. This will update automatically on new commits. Configure here.