Jump to solution
Verify

The Fix

pip install stripe==14.4.0a2

Based on closed stripe/stripe-python issue #1562 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -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
repro.py
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
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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

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…”
@mbroshi-stripe · 2025-09-05 · confirmation · source
“Following up here: 1”
@mbroshi-stripe · 2025-09-02 · source
“👋 Hi @ryancausey ! Thanks for reporting this issue, and the carefully written description! I will begin investigating this issue and circle back as needed.”
@mbroshi-stripe · 2025-09-02 · source
“> 2”
@ryancausey · 2025-09-05 · source

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
signature.txt
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.txt
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

repro.py
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

When NOT to use: Do not use this fix if the logic for handling pagination needs to remain unchanged.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if the logic for handling pagination needs to remain unchanged.

Verify Fix

verify
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

VersionStatus
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.