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(braze): stop sending offset=0 which Braze rejects with 400 (#70346)

Tom Owersc56d7b88969d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braze/braze.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braze/braze.py
index 0aeec889a3b2..d66224507d23 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braze/braze.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braze/braze.py
@@ -77,7 +77,11 @@ def _build_params(config: BrazeEndpointConfig, cursor: int, modified_after: str
if config.pagination == "page":
params = {"page": cursor}
else:
- params = {"limit": config.page_size, "offset": cursor}
+ # Braze's offset endpoints reject offset=0 (offset must be a positive integer),
+ # so omit it on the first page — equivalent to skipping nothing.
+ params = {"limit": config.page_size}
+ if cursor:
+ params["offset"] = cursor
if modified_after and config.modified_after_param:
params[config.modified_after_param] = modified_after
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braze/tests/test_braze.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braze/tests/test_braze.py
index c781a6af89d6..e7b17f5e78b0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braze/tests/test_braze.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braze/tests/test_braze.py
@@ -78,6 +78,11 @@ class TestBuildParams:
params = _build_params(BRAZE_ENDPOINTS["email_templates"], cursor=200, modified_after=None)
assert params == {"limit": 100, "offset": 200}
+ def test_offset_omitted_on_first_page(self):
+ # Braze 400s on offset=0, so the first page must not carry an offset param.
+ params = _build_params(BRAZE_ENDPOINTS["email_templates"], cursor=0, modified_after=None)
+ assert params == {"limit": 100}
+
def test_modified_after_added_only_for_incremental_endpoint(self):
params = _build_params(BRAZE_ENDPOINTS["email_templates"], cursor=0, modified_after="2026-01-01T00:00:00+00:00")
assert params["modified_after"] == "2026-01-01T00:00:00+00:00"
@@ -189,7 +194,8 @@ class TestGetRows:
list(get_rows("key", BASE_URL, "email_templates", mock.MagicMock(), manager, team_id=1))
urls = [call.args[0] for call in mock_session.return_value.get.call_args_list]
- assert "offset=0" in urls[0]
+ # First page omits offset (Braze rejects offset=0); later pages advance by page size.
+ assert "offset=" not in urls[0]
assert "limit=100" in urls[0]
assert "offset=100" in urls[1]