fix: Add empty string cursor support for pagination endpoint#33
Merged
Conversation
2ynn
reviewed
Aug 22, 2025
2ynn
approved these changes
Aug 26, 2025
| if ok && len(vals) > 0 { | ||
| endCursor = &vals[0] | ||
| } | ||
| handleNonNumericCursorWithEndCursor(w, r, endCursor) |
There was a problem hiding this comment.
I wonder if it's really necessary to have a separate helper function
Comment on lines
267
to
272
| if len(res.ResultArray) == limit { | ||
| cursor, _ := res.ResultArray[len(res.ResultArray)-1].(string) | ||
| res.Cursor = &cursor | ||
| } else if endCursor != nil { | ||
| res.Cursor = endCursor | ||
| } |
There was a problem hiding this comment.
If len(res.ResultArray) == limit && endCursor != nil then we will always fall in the first condition. Is that fine ?
Author
There was a problem hiding this comment.
Yes, we iterate until hit the condition where the page is not full and only then return empty cursor @kanwardeep007
kanwardeep007
approved these changes
Aug 28, 2025
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.
Add empty string cursor support for pagination endpoint
This PR adds support for returning an empty string cursor in the non-numeric cursor pagination endpoint when the endCursor parameter
is set to #emptyString.
Changes:
The change is needed to test for bugs described here: https://linear.app/speakeasy/issue/GEN-1759/bug-empty-cursor-values-not-properly-handled-for-termination