feat(referrer): add cursor-based pagination to discover endpoints#2896
Open
migmartri wants to merge 5 commits intochainloop-dev:mainfrom
Open
feat(referrer): add cursor-based pagination to discover endpoints#2896migmartri wants to merge 5 commits intochainloop-dev:mainfrom
migmartri wants to merge 5 commits intochainloop-dev:mainfrom
Conversation
Add optional cursor-based pagination to DiscoverPrivate and DiscoverPublicShared RPCs. References inside ReferrerItem are now paginated using keyset pagination on (created_at, id), defaulting to 20 items per page. Existing clients that omit pagination get the first page transparently. CLI gains --limit and --next flags on `referrer discover`. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Entire-Checkpoint: 2495d6f80461
There was a problem hiding this comment.
1 issue found across 19 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/controlplane/pkg/data/referrer.go">
<violation number="1" location="app/controlplane/pkg/data/referrer.go:243">
P1: Ordering is not actually descending: `ent.Desc()` is called without fields, so keyset pagination uses the wrong sort direction and can return incorrect pages.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
ent.Desc() with no arguments is a no-op, so the query was ordering ASC instead of DESC. This caused CompositeLT cursor comparisons to find no rows after the first page. Use ent.Desc(fields...) to match the pattern used in workflowrun.go. Also regenerate CLI docs to include the new pagination flags. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
- Return nil pagination opts when proto request has no pagination field, preserving backward compatibility (all references returned for old clients). - Merge CLI pagination hint into a single log message without trailing \n. - Make test assertions order-independent since DESC ordering changes reference order non-deterministically when timestamps are equal. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/controlplane/internal/service/referrer.go">
<violation number="1" location="app/controlplane/internal/service/referrer.go:114">
P2: This now uses the global cursor default (10) when pagination is present without `limit`, which changes the referrer endpoint default page size from 20 to 10.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
ent.Desc() without field arguments is a no-op. Use sql.OrderDesc() as OrderTermOption to ByCreatedAt/ByID for correct descending sort in pagination queries. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Entire-Checkpoint: 2dc882476ce5
When a CursorPaginationRequest is present without an explicit limit, default to 20 instead of the global cursor default of 10. This matches the spec requirement for the referrer endpoints. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Entire-Checkpoint: 7b9d8e75f733
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.
Summary
created_at, id) toDiscoverPrivateandDiscoverPublicSharedRPCs, defaulting to 20 items per pagereferrer discovergains--limitand--nextflags following the workflow run list patternTest plan