fix(snippets): implement pagination for snippets list command#4879
Open
angeliski wants to merge 1 commit intosupabase:developfrom
Open
fix(snippets): implement pagination for snippets list command#4879angeliski wants to merge 1 commit intosupabase:developfrom
angeliski wants to merge 1 commit intosupabase:developfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds pagination to the snippets list: the list function now loops using a Sequence Diagram(s)sequenceDiagram
participant Client
participant ListFunction as List Function
participant API as Snippets API
participant Renderer
Client->>ListFunction: Invoke list (optional project_ref)
ListFunction->>ListFunction: set currentCursor = ""
ListFunction->>ListFunction: set Limit = defaultLimit
loop while currentCursor != nil
ListFunction->>API: GET /snippets?Limit=Limit&Cursor=currentCursor
API-->>ListFunction: { data: [...], cursor: "next_page" }
ListFunction->>ListFunction: append response to allResponses
alt cursor present
ListFunction->>ListFunction: update currentCursor = "next_page"
else no cursor
ListFunction->>ListFunction: set currentCursor = nil
end
end
ListFunction->>Renderer: send flattened allResponses for output (table/JSON/TOML)
Renderer-->>Client: display aggregated snippets
Comment |
Pull Request Test Coverage Report for Build 22239486744Details
💛 - Coveralls |
- Add cursor-based pagination support to fetch all snippets across multiple pages - Implement proper pagination loop with cursor tracking - Add comprehensive unit tests for pagination and output formats - Support JSON, TOML, and table output formats - Simplify code to use native API types without unnecessary conversions - All tests passing Closes supabase#4858
325bd0b to
91143fd
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.
What kind of change does this PR introduce?
Bug fix - Implement pagination support for snippets list command
What is the current behavior?
The
supabase snippets listcommand was not implementing pagination correctly, returning only the first page of results and not fetching subsequent pages via cursor-based pagination.Related to #4858
I
What is the new behavior?
✅ Implemented cursor-based pagination that:
Example usage:
Additional context
Design Decision - Pagination-Only Approach:
This PR intentionally focuses on implementing pagination without introducing additional filtering or sorting parameters (e.g., --limit, --sort-by, --sort-order). The rationale behind this approach:
Consistency: Follows the existing CLI pattern where pagination is handled transparently without user-exposed parameters
Simplicity: Reduces cognitive load - users simply run the command and get all results, without needing to understand pagination mechanics
API Alignment: Mirrors the behavior of similar Supabase CLI commands (databases list, functions list, etc.)
Scope: Keeps the fix focused on resolving the reported issue without scope creep
Future Improvements:
Sorting and limiting capabilities could be valuable additions in a subsequent PR if deemed necessary:
--limit could cap the number of results retrieved
--sort-by and --sort-order could organize results (though the API's cursor-based model makes client-side sorting more practical)
However, pagination (fetching all available results) was the primary blocker and is now fully functional.