: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(cloudflare): skip zones that reject the legacy firewall rules API (#99101)
Tom Owers426a9e8fcf73
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.pyindex 68fd272d3a9f..6c9f73a9b38f 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@@ -67,17 +67,22 @@ CLOUDFLARE_ENDPOINTS: dict[str, CloudflareEndpointConfig] = {parent_key="_zone_id",),# --- Zone-scoped security configuration ---+ # Cloudflare deprecated the legacy Firewall Rules API (and the Filters API its rules+ # reference) in favor of the Ruleset Engine; a zone that has moved to WAF custom rules+ # gets a 400 on both rather than an empty list. Same shape as `rate_limits` below."firewall_rules": CloudflareEndpointConfig(name="firewall_rules",path="/zones/{zone_id}/firewall/rules",parent=ZONES_PARENT,parent_key="_zone_id",+ extra_skip_status_codes=(400,),),"filters": CloudflareEndpointConfig(name="filters",path="/zones/{zone_id}/filters",parent=ZONES_PARENT,parent_key="_zone_id",+ extra_skip_status_codes=(400,),),"rulesets": CloudflareEndpointConfig(name="rulesets",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.pyindex b905690fade9..790470088056 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@@ -231,12 +231,18 @@ class TestZoneFanout:@pytest.mark.parametrize(("endpoint", "status_code"),- [("rate_limits", 410), ("custom_certificates", 400)],+ [+ ("rate_limits", 410),+ ("custom_certificates", 400),+ ("firewall_rules", 400),+ ("filters", 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 (e.g. legacy rate limiting is 410 Gone, custom certs are 400) rather+ # 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# than an empty list — one such zone must not abort the whole stream.session = MockSession.return_value_wire(