Repository navigation
Follow next_page_token in SearchEntitlements - #156
chinkulkarni wants to merge 1 commit into
Conversation
The request catalog search-entitlements endpoint is starting to return paginated results. SearchEntitlements issued a single request with page_size 100 and ignored next_page_token, so a client talking to a paginated server would silently truncate results to the first page. Loop on next_page_token, passing it back on each request until it is empty, and accumulate the results. Expanded objects are referenced by index into each response's own expanded array, so each page is resolved against its own expanded objects before the results are appended. Context cancellation is checked between pages. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <[email protected]>
Superseded — see the current review report for commit
|
| if body.NextPageToken == nil || *body.NextPageToken == "" { | ||
| break | ||
| } | ||
| pageToken = body.NextPageToken |
There was a problem hiding this comment.
🟡 Suggestion (medium confidence): nothing guards against a server that keeps returning the same next_page_token (or a cycle of tokens). That case loops forever and keeps growing rv until ctx is cancelled, and most CLI callers pass a context with no deadline. Consider breaking or erroring when *body.NextPageToken == StringFromPtr(pageToken), and/or capping the page count.
General PR Review: Follow next_page_token in SearchEntitlementsBlocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review Summary
Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agentsReviewed commit: |
Problem
SearchEntitlementsinpkg/client/entitlement.gomade a single search request (page size 100) and ignorednext_page_token. The server is starting to return paginated results for this endpoint, so a single-page client silently truncates results (affectingsearch-entitlements,generate-alias,aws, and entitlement lookup inget-drop-task).Change
SearchEntitlementsnow loops onnext_page_token, passing it back until it is empty, keeping page size 100 and the existing return type and error handling. It checks ctx cancellation between pages.expandedarray, so each page is resolved against its own expanded list before results are appended (merging arrays across pages would make the indexes wrong). Callers only read per-entitlement expanded maps, so none needed changes.Testing
go build ./...andgo test ./pkg/... ./cmd/...pass.pkg/client/entitlement_test.go: an httptest server serving three pages, asserting tokens are passed back, results are accumulated in order, and each entitlement resolves its own page's expanded app (every page usesexpanded[0]); plus a ctx cancellation test.🤖 Generated with Claude Code