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(cloudflare): skip zones that reject the page rules API (#107647)

Tom Owers92e4bd68e3a8
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/settings.py
index 6c9f73a9b38f..e7ce884d55fb 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/settings.py
@@ -138,6 +138,10 @@ CLOUDFLARE_ENDPOINTS: dict[str, CloudflareEndpointConfig] = {
parent=ZONES_PARENT,
parent_key="_zone_id",
pagination=SINGLE_PAGE,
+ # Cloudflare is replacing Page Rules with the Ruleset Engine; a zone that doesn't
+ # serve the legacy API gets a 400 rather than an empty list, same as the firewall
+ # rules and filters above.
+ extra_skip_status_codes=(400,),
),
"snippets": CloudflareEndpointConfig(
name="snippets",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/tests/test_cloudflare_client.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/tests/test_cloudflare_client.py
index 2295e9952306..14e1f43fc226 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/tests/test_cloudflare_client.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cloudflare/tests/test_cloudflare_client.py
@@ -328,13 +328,14 @@ class TestZoneFanout:
("custom_certificates", 400),
("firewall_rules", 400),
("filters", 400),
+ ("pagerules", 400),
],
)
@mock.patch(CLIENT_SESSION_PATCH)
def test_skips_zone_missing_plan_feature_and_continues(self, MockSession, endpoint, status_code) -> None:
# Cloudflare returns a non-403/404 error when a zone's plan doesn't include a
# feature, or when it has moved off a deprecated API (legacy rate limiting is
- # 410 Gone, custom certs and the legacy firewall rules/filters are 400), rather
+ # 410 Gone, custom certs, page rules and the legacy firewall rules/filters are 400), rather
# than an empty list — one such zone must not abort the whole stream.
session = MockSession.return_value
_wire(