File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,11 @@ class V4PagePaginationArrayResultInfo(BaseModel):
8484
8585 per_page : Optional [int ] = None
8686
87+ # Added missing fields present in V4 API
88+ total_pages : Optional [int ] = None
89+ total_count : Optional [int ] = None
90+ count : Optional [int ] = None
91+
8792
8893class SyncV4PagePaginationArray (BaseSyncPage [_T ], BasePage [_T ], Generic [_T ]):
8994 result : List [_T ]
@@ -100,6 +105,10 @@ def _get_page_items(self) -> List[_T]:
100105 def next_page_info (self ) -> Optional [PageInfo ]:
101106 last_page = cast ("int | None" , self ._options .params .get ("page" )) or 1
102107
108+ # Guard against infinite loops where API returns data past the last page
109+ if self .result_info and self .result_info .total_pages is not None and last_page >= self .result_info .total_pages :
110+ return None
111+
103112 return PageInfo (params = {"page" : last_page + 1 })
104113
105114
@@ -118,6 +127,9 @@ def _get_page_items(self) -> List[_T]:
118127 def next_page_info (self ) -> Optional [PageInfo ]:
119128 last_page = cast ("int | None" , self ._options .params .get ("page" )) or 1
120129
130+ # Guard against infinite loops where API returns data past the last page
131+ if self .result_info and self .result_info .total_pages is not None and last_page >= self .result_info .total_pages :
132+ return None
121133 return PageInfo (params = {"page" : last_page + 1 })
122134
123135
You can’t perform that action at this time.
0 commit comments