cloudflare / cloudflare/cloudflare-go

Gateway List Items ListAutoPaging does not fetch subsequent pages

Open
#4,351 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.1k
Forks
781
Avg merge
12h 38m
Merged PRs (30d)
4

Description

### Confirm this is a Go library issue and not an underlying Cloudflare API issue

- [x] This is an issue with the Go library

### Describe the bug

With `cloudflare-go/v7` v7.7.0, `Gateway.Lists.Items.ListAutoPaging` only returns items from the first API page.

The endpoint appears to use `SinglePageAutoPager`, even though the API response contains pagination information such as `result_info.page` and `result_info.total_count`.

As a workaround, we repeatedly call `Gateway.Lists.Items.List` with explicit `page` and `per_page` query parameters.

### To Reproduce

1. Create a Gateway List containing more than 50 items.
2. Fetch its items using `Gateway.Lists.Items.ListAutoPaging`.
3. Iterate over the pager until `Next()` returns false.
4. Observe that only the first 50 items are returned and no subsequent API page is requested.

Expected: all items are returned.

Actual: only items from the first page are returned.

### Code snippets

```Go
pager := client.ZeroTrust.Gateway.Lists.Items.ListAutoPaging(
ctx,
listID,
zero_trust.GatewayListItemListParams{
AccountID: cloudflare.F(accountID),
},
)

count := 0
for pager.Next() {
count++
}
if err := pager.Err(); err != nil {
return err
}

fmt.Println(count)
// For a list containing 51 items, this prints 50.
```

### OS

Ubuntu

### Go version

Go 1.26

### Library version

v7.7.0

Contributor guide

Open the contributing guide

Research direction

Start at Gateway.Lists.Items.ListAutoPaging and compare its behavior with Gateway.Lists.Items.List, using a Gateway List containing more than 50 items. Iterate until Next() returns false and verify that the pager requests subsequent API pages and returns all items, including the 51-item reproduction case.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.