⚡ 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

barreeeiroo 2025-12-02
I can share a recording of the test with more details via some private channel, given it would disclose more IDs than just Prices unfortunately. But yes, I can just keep re-running it, and it randomly returns repeated results on paging iteration (basically the last item of page 1 is also included in first item of page 2). Not sure if this is a bug in the Python SDK or in the API itself though...
barreeeiroo 2025-12-02
The issue is in the API actually, not in the Python client, I was able to replicate this using the Shell from the Workbench: <img width="1124" height="1037" alt="Image" src="https://github.com/user-attachments/assets/7e607324-7e5e-4194-b3d3-d54cb555e01a" /> And it happens randomly actually: <img width="1044" height="1096" alt="Image" src="https://github.com/user-attachments/assets/a983a666-1169-4c88-ada4-adcfa24fbd25" />
mbroshi-stripe 2025-12-16
👋 Hi @barreeeiroo ! Thanks for creating this issue and doing the initial triage! I've routed this issue to the team that owns the `/v1/prices` API, and they will investigate the issue.
mbroshi-stripe 2025-12-16
Circling back! After additional investigation, I've learned: 1. This is unfortunately a known limitation with our Search APIs: https://docs.stripe.com/search#pagination 2. Fortunately, the work to address the root cause in our Search API is under way. I'll update this ticket once that work is complete. As a workaround, this issue just affects paginated results, so having a larger page size will help mitigate if that's an option for you. You can also filter out duplicates client-side, although there is still the possibility of missing a record when you paginate (until the bug is fixed in Search).
barreeeiroo 2025-12-16
Hi @mbroshi-stripe, thanks for the quick update. Is there any ETA on when this issue might get resolved? I'll increase the page size in the meantime following the recommendation.
mbroshi-stripe 2025-12-16
I unfortunately cannot give you a timeline, but know that the Search team is aware of the issue and is planning a fix. Reaching out to Support might be the best way to get more detailed information on timeline, and have your use case known to that team.
mbroshi-stripe 2026-01-06
Hi @barreeeiroo ! Quick follow-up here: The Search team has addressed the underlying issue, and I have verified that I can no longer reproduce the behavior you reported in the SDK. I'm closing out this issue, but feel free to re-open if you are still seeing the behavior.