The Fix
pip install stripe==14.4.0a2
Based on closed stripe/stripe-python issue #1562 · PR/commit linked
@@ -132,8 +132,8 @@ def _auto_paging_iter(self) -> Iterator[T]:
while True:
if (
- "ending_before" in self._retrieve_params
- and "starting_after" not in self._retrieve_params
+ self._retrieve_params.get("ending_before") is not None
def _auto_paging_iter(self) -> Iterator[T]:
page = self
while True:
if (
"ending_before" in self._retrieve_params
and "starting_after" not in self._retrieve_params
):
for item in reversed(page):
yield item
page = page.previous_page()
else:
for item in page:
yield item
page = page.next_page()
if page.is_empty:
break
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install stripe==14.4.0a2\nWhen NOT to use: Do not use this fix if the logic for handling pagination needs to remain unchanged.\n\n
Why This Fix Works in Production
- Trigger: `auto_paging_iter` does not paginate backwards if `starting_after` is `None`
- Mechanism: The `auto_paging_iter` incorrectly handles `starting_after` being None, preventing backward pagination
- Why the fix works: Fixes the case where `starting_after` is present in `_retrieve_params` but is `None`, ensuring that the `auto_paging_iter` correctly paginates backwards. (first fixed release: 14.4.0a2).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Shows up under Python 3.13.3 in real deployments (not just unit tests).
- The `auto_paging_iter` incorrectly handles `starting_after` being None, preventing backward pagination
- Production symptom (often without a traceback): `auto_paging_iter` does not paginate backwards if `starting_after` is `None`
Proof / Evidence
- GitHub issue: #1562
- Fix PR: https://github.com/stripe/stripe-python/pull/1563
- First fixed release: 14.4.0a2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.56
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@ryancausey It actually turned out that your PR fixed both! Thanks again for bringing up and fixing the issue. 🚀 I just released it as…”
“Following up here: 1”
“👋 Hi @ryancausey ! Thanks for reporting this issue, and the carefully written description! I will begin investigating this issue and circle back as needed.”
“> 2”
Failure Signature (Search String)
- `auto_paging_iter` does not paginate backwards if `starting_after` is `None`
- This leads to an incorrect pagination after the first page of results, because it uses the wrong cursors and arguments to retrieve the next page.
Copy-friendly signature
Failure Signature
-----------------
`auto_paging_iter` does not paginate backwards if `starting_after` is `None`
This leads to an incorrect pagination after the first page of results, because it uses the wrong cursors and arguments to retrieve the next page.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
`auto_paging_iter` does not paginate backwards if `starting_after` is `None`
This leads to an incorrect pagination after the first page of results, because it uses the wrong cursors and arguments to retrieve the next page.
Minimal Reproduction
def _auto_paging_iter(self) -> Iterator[T]:
page = self
while True:
if (
"ending_before" in self._retrieve_params
and "starting_after" not in self._retrieve_params
):
for item in reversed(page):
yield item
page = page.previous_page()
else:
for item in page:
yield item
page = page.next_page()
if page.is_empty:
break
Environment
- Python: 3.13.3
What Broke
Incorrect pagination occurs, leading to wrong results when iterating invoices.
Why It Broke
The `auto_paging_iter` incorrectly handles `starting_after` being None, preventing backward pagination
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install stripe==14.4.0a2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/stripe/stripe-python/pull/1563
First fixed release: 14.4.0a2
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the logic for handling pagination needs to remain unchanged.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 14.4.0a2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.