Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(stripe): page v2 money management lists at 50, not 100 (#127476)

Tom Owers93b507ddce9a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py
index 215344359dae..dc4f2ee97048 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py
@@ -123,6 +123,9 @@ if TYPE_CHECKING:
LOGGER = get_logger(__name__)
DEFAULT_LIMIT = 100
+# Stripe's v2 Money Management list endpoints (V2_LIST_PATHS) cap `limit` at 50, unlike the v1
+# lists' 100 — requesting DEFAULT_LIMIT against one raises "Limit must be between 1 and 50".
+V2_LIST_PAGE_LIMIT = 50
# Subscriptions are fetched with two levels of `expand` (subscription discounts and per-line-item
# discounts), so each object is far larger than a typical Stripe resource. A full page of 100 such
# objects can grow past the size that reliably transfers intact, and the response then arrives
@@ -1073,7 +1076,10 @@ def get_rows(
# A v2 page token cannot be saved as a v1 `starting_after` cursor, so these full-refresh tables
# save no resume state. An interrupted sync reads the list again and overwrites the table.
yield from _batch_and_yield(
- _iter_cleaning_errors(_call_stripe(resource.method, params=default_params).auto_paging_iter()), batcher
+ _iter_cleaning_errors(
+ _call_stripe(resource.method, params={"limit": V2_LIST_PAGE_LIMIT}).auto_paging_iter()
+ ),
+ batcher,
)
return
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
index c64f1fca8171..3170affaa319 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
@@ -110,6 +110,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.stripe.sou
from products.warehouse_sources.backend.temporal.data_imports.sources.stripe.stripe import (
DEFAULT_LIMIT,
SUBSCRIPTION_PAGE_LIMIT,
+ V2_LIST_PAGE_LIMIT,
StripeAuthenticationError,
StripeNestedResource,
StripeResource,
@@ -360,6 +361,9 @@ class TestStripeApiVersionDispatch:
assert [row["id"] for table in result.rows for row in table.to_pylist()] == ["obp_2", "obp_1"]
assert result.paths == [path, path]
assert {request.headers["stripe-version"] for request in result.requests} == {STRIPE_API_VERSION_ENDIVE}
+ # The v2 Money Management list endpoints reject DEFAULT_LIMIT (100) with "Limit must be
+ # between 1 and 50" — the first request must ask for the v2-specific page size instead.
+ assert result.requests[0].param("limit") == str(V2_LIST_PAGE_LIMIT)
# A saved cursor would mark the next attempt as resumed, and a resumed full refresh appends.
assert result.saved_states == []