cloudflare / cloudflare/cloudflare-python

client.rules.lists.items.list - Pagination not working

Offen
#2,667 5 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
506
Forks
148
Ø Merge
3 Std. 15 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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

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

### Describe the bug

Hi there,

It appears as though pagination is not working for `client.rules.lists.items.list()`. I am only getting the first page back. I've taken a look at the source code and it appears it could be related to the removal of SyncCursorPagination? I'm rusty as a dev so I wouldn't put money on it.

Please check out this PR though ([here](https://github.com/cloudflare/cloudflare-python/commit/0e950d65a750fb3741d8728c980e804d658c0306#diff-06d57421adecb656bf71894319342166d32fdd4fe9c2e09319e1b15d0c8f9f3eL168-R176)) which looks to have made a change. For now the list I have is around 480 items so I'm getting around this with `client.rules.lists.items.list(account_id=account_id, list_id=rule_id, per_page=500)` but this is a stop-gap solution at best.

See "To Reproduce" for a very basic reproduction.

Any help would be greatly appreciated!

### To Reproduce

```
import os
from cloudflare import Cloudflare

client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)

ip_list = []
rule_id = "xxxxx"
account_id = "xxxxx"

for item in client.rules.lists.items.list(list_id=rule_id, account_id=account_id):
ip_list.append(account)
print(ip_list)
```

### Code snippets

```Python

```

### OS

macOS

### Python version

3.11.2

### Library version

4.3.1

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Einstiegspunkt client.rules.lists.items.list() und reproduziere das Problem anhand des Beispiels mit einer Liste, die größer als eine Seite ist. Untersuche die Verarbeitung der Paginierung und vergleiche sie mit der zitierten Änderung an SyncCursorPagination; fertig ist die Aufgabe, wenn die Iteration alle Listenelemente zurückgibt, ohne einen übergroßen per_page-Wert zu erfordern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.