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(netlify): skip a site that doesn't serve a fan-out sub-resource (#102868)

Tom Owers00cbb68d878b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/netlify.py b/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/netlify.py
index aba35e9be5e8..7cfd8de8ff43 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/netlify.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/netlify.py
@@ -258,6 +258,11 @@ def _build_fan_out_resource(
},
),
"paginator": NetlifyCappedHeaderLinkPaginator(config.max_pages_per_parent, context={"table": config.name}),
+ # A site-scoped sub-resource answers 404 when the site doesn't serve it at all (a site with
+ # form detection off has no /forms), and when a site listed by the parent is deleted before
+ # its children are fetched. Both mean this parent contributes no rows, not that the table
+ # can't sync, so skip the parent instead of failing every other site's rows with it.
+ "response_actions": [{"status_code": 404, "action": "ignore"}],
}
child_resource: EndpointResource = {
"name": config.name,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/tests/test_netlify.py b/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/tests/test_netlify.py
index 738f00843289..dff3eb6b6ff6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/tests/test_netlify.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/netlify/tests/test_netlify.py
@@ -214,6 +214,26 @@ class TestFanOut:
# Members fan out over accounts keyed by the account slug, injected as account_slug.
assert rows == [{"id": "u1", "email": "[email protected]", "account_slug": "acme"}]
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_skips_a_parent_that_does_not_serve_the_child_resource(self, MockSession) -> None:
+ session = MockSession.return_value
+
+ def route(url: str) -> Response:
+ if url == f"{BASE}/sites?filter=all&per_page=100":
+ return _response([{"id": "s1"}, {"id": "s2"}], next_url=None)
+ if url == f"{BASE}/sites/s1/forms":
+ return _response({"message": "Not Found"}, status=404)
+ if url == f"{BASE}/sites/s2/forms":
+ return _response([{"id": "f2"}], next_url=None)
+ raise AssertionError(f"unexpected url: {url}")
+
+ _wire(session, route)
+ rows = _rows(_source("forms", _manager()))
+
+ # A site with form detection off 404s on /forms. That parent holds no rows, so the table
+ # still syncs every other site rather than failing the whole sync.
+ assert rows == [{"id": "f2", "site_id": "s2"}]
+
@mock.patch(CLIENT_SESSION_PATCH)
def test_resumes_fanout_from_saved_state_skipping_completed_parent(self, MockSession) -> None:
session = MockSession.return_value