⚡ Solution Summary
- Known limitation with Search API pagination causing duplicates
- Larger page sizes may mitigate the issue
- Client-side filtering for duplicates is a workaround
- Ongoing work to address the root cause in Search API.
### Describe the bug
This is a strange bug, as it happens randomly. I do have to run the same test multiple times, and it happens maybe on 40%-60% of the instances.
The issue I'm facing is that `auto_paging_iter` is iterating, and consequently returning, the same item twice.
I'm trying to call `search_prices` API, and I do have 15 prices to be returned. I'm filtering `active=true` and some metadata fields. Then, I do the following:
```python
prices: List[Price] = []
res = client.prices.search(params={"query": query_str})
print(res)
for price in res.auto_paging_iter():
print(f"Real adding {price.id}")
prices.append(price)
```
In the first response, I see `price_1SH9GKCjrU80UaAVjS6Nm5aL` being returned as the last entry. Then, in the logs, I see this:
```
Real adding ...
Real adding price_1SH9GKCjrU80UaAVjS6Nm5aL
Real adding price_1SH9GKCjrU80UaAVjS6Nm5aL
Real adding ...
```
Could it be possible that the auto paging iterator is not properly respecting the `next_page` key, and is "repeatedly returning" the same item twice?
### To Reproduce
1. Call Prices Search API with `auto_paging_iterator`, with `active=true` and some metadata fields.
2. Make sure there are over 10 prices matching, to force pagination.
3. Log the unique IDs. At position 10 (default page size), it may sometimes be duplicated.
### Expected behavior
`auto_paging_iter` should not iterate over duplicated prices
### Code snippets
```Python
See above
```
### OS
Linux
### Language version
Python 3.13
### Library version
stripe 12.3.0
### API version
2025-03-31.basil
### Additional context
_No response_
Discussion & Fixes