-
Notifications
You must be signed in to change notification settings - Fork 473
Description
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:
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
- Call Prices Search API with
auto_paging_iterator, withactive=trueand some metadata fields. - Make sure there are over 10 prices matching, to force pagination.
- 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
See aboveOS
Linux
Language version
Python 3.13
Library version
stripe 12.3.0
API version
2025-03-31.basil
Additional context
No response