Skip to content

Return the cursor when listing applications without label filter - #7101

Merged
khanhtc1202 merged 2 commits into
pipe-cd:masterfrom
vipulpandey21:fix/list-applications-missing-cursor
Aug 4, 2026
Merged

Return the cursor when listing applications without label filter#7101
khanhtc1202 merged 2 commits into
pipe-cd:masterfrom
vipulpandey21:fix/list-applications-missing-cursor

Conversation

@vipulpandey21

@vipulpandey21 vipulpandey21 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

Sets the Cursor field on the response APIService.ListApplications returns when the request has no label filter.

 	if len(req.Labels) == 0 {
 		return &apiservice.ListApplicationsResponse{
 			Applications: apps,
+			Cursor:       cursor,
 		}, nil
 	}

Why we need it:

That early return was the only path in the function that did not set the cursor, so a client without a label filter always received an empty cursor and could not ask for the next page. pipectl application list has a documented --cursor flag but there was no value to pass to it.

The other two returns in the same function set it, and ListDeployments sets it in the same situation. It also used to be set here before #4186 added label filtering. Details and the history I looked at are in #7100.

I kept this to the one line. The label filtering loop below it has its own paging behaviour, which I did not touch.

How I tested it

Added TestListApplicationsCursor covering both the no label and the with label case.

Without the fix the no label case fails:

--- FAIL: TestListApplicationsCursor/cursor_is_returned_when_no_label_filter_is_given
    Error:      Not equal:
                expected: "next-page-cursor"
                actual  : ""

With the fix:

--- PASS: TestListApplicationsCursor
    --- PASS: .../cursor_is_returned_when_no_label_filter_is_given
    --- PASS: .../cursor_is_returned_when_a_label_filter_is_given
ok  	github.com/pipe-cd/pipecd/pkg/app/server/grpcapi

go test ./pkg/app/server/grpcapi/... passes, and go build ./cmd/pipecd ./cmd/pipectl is fine.

One thing I wanted to be sure about before changing this: whether handing back a real cursor could make a client loop forever. It cannot, because applicationStore.List returns an empty cursor once there are no more records:

// In case there is no more elements found, cursor should be set to empty too.
if len(apps) == 0 {
    return apps, "", nil
}

So a client that loops until the cursor is empty still terminates.

Which issue(s) this PR fixes:

Fixes #7100

Does this PR introduce a user-facing change?:

  • How are users affected by this change: ListApplications and pipectl application list return a usable cursor when no label filter is given, so paging past the first page works. A client that loops until the cursor is empty now walks through all applications instead of stopping after the first page.
  • Is this breaking change: No
  • How to migrate (if breaking change): Not applicable

ListApplications returns early when no label filter is given, and that
path was not setting the Cursor field, so clients could never move to
the next page. ListDeployments sets it in the same situation.

Fixes pipe-cd#7100

Signed-off-by: Vipul Subhash Pandey <vipulpandey7917@gmail.com>

@khanhtc1202 khanhtc1202 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, lgtm 👍

@khanhtc1202
khanhtc1202 enabled auto-merge (squash) August 4, 2026 07:34
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.27%. Comparing base (eb4db49) to head (1d9add7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7101      +/-   ##
==========================================
- Coverage   29.36%   28.27%   -1.09%     
==========================================
  Files         601       23     -578     
  Lines       64328     1712   -62616     
==========================================
- Hits        18887      484   -18403     
+ Misses      43972     1184   -42788     
+ Partials     1469       44    -1425     
Flag Coverage Δ
. ?
.-pkg-app-pipedv1-plugin-analysis ?
.-pkg-app-pipedv1-plugin-ecs ?
.-pkg-app-pipedv1-plugin-kubernetes ?
.-pkg-app-pipedv1-plugin-kubernetes_multicluster ?
.-pkg-app-pipedv1-plugin-scriptrun ?
.-pkg-app-pipedv1-plugin-terraform 38.46% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait ?
.-pkg-app-pipedv1-plugin-waitapproval 52.71% <ø> (ø)
.-pkg-plugin-sdk ?
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview ?
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@khanhtc1202
khanhtc1202 merged commit ad4565f into pipe-cd:master Aug 4, 2026
61 of 62 checks passed
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thank you for contributing to PipeCD, @vipulpandey21! The changes in this pull request will be part of the upcoming release!

@khanhtc1202 khanhtc1202 added cherry-pick v0.57.1 Release v0.57.1 labels Aug 5, 2026
@github-actions github-actions Bot mentioned this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListApplications does not return the cursor when no label filter is given

2 participants