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(data-imports): skip Render services that can't have custom domains (#72314)

Tom Owersbb345bdfde90
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/render/render.py b/products/warehouse_sources/backend/temporal/data_imports/sources/render/render.py
index f87b4d6ebc71..3c2392758f3d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/render/render.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/render/render.py
@@ -90,8 +90,10 @@ def _fetch_page(
raise RenderRetryableError(f"Render API error (retryable): status={response.status_code}, url={url}")
if not response.ok:
- # 404 is expected during fan-out (a service deleted mid-sync) and handled by the caller.
- log = logger.warning if response.status_code == 404 else logger.error
+ # 404 (a service deleted mid-sync) and 400 (a service type that can't own the child
+ # resource, e.g. custom domains on a cron job) are expected during fan-out and handled
+ # by the caller — log them as warnings. Anything else is a genuine error.
+ log = logger.warning if response.status_code in (400, 404) else logger.error
log(f"Render API error: status={response.status_code}, body={response.text}, url={url}")
response.raise_for_status()
@@ -303,10 +305,15 @@ def _get_fan_out_rows(
if next_cursor:
resumable_source_manager.save_state(RenderResumeConfig(cursor=next_cursor, parent_id=parent_id))
except requests.HTTPError as exc:
+ status = exc.response.status_code if exc.response is not None else None
# A parent deleted between enumeration and this fetch 404s. Skip it rather than
# failing the whole sync — the resource is genuinely gone.
- if exc.response is not None and exc.response.status_code == 404:
+ if status == 404:
logger.warning(f"Render: {config.parent} {parent_id} not found while fetching {config.name}, skipping")
+ # Render 400s the child endpoint for parents that can't own the resource (custom
+ # domains on non-web/static services). Skip them instead of failing the sync.
+ elif status == 400 and config.skip_parent_on_bad_request:
+ logger.warning(f"Render: {config.parent} {parent_id} cannot have {config.name}, skipping")
else:
raise
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/render/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/render/settings.py
index b3e8a666d143..175057321e5c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/render/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/render/settings.py
@@ -52,6 +52,10 @@ class RenderEndpointConfig:
# Hard cap on pages fetched per parent in a fan-out, to bound runaway pagination.
# A structured warning is logged if the cap is reached.
max_pages_per_parent: int = 500
+ # Fan-out children where Render 400s parents that can't own the resource (custom domains
+ # only exist for web services and static sites, not cron jobs, workers or private
+ # services). Skip those parents rather than failing the whole sync.
+ skip_parent_on_bad_request: bool = False
# Some endpoints return secrets the API key is only meant to *use* for sync (env var
# values, secret-file contents), not data worth warehousing. Maps a list column to the
# item keys whose values are redacted before a row is yielded, keeping the safe metadata
@@ -167,6 +171,7 @@ RENDER_ENDPOINTS: dict[str, RenderEndpointConfig] = {
# creation — a createdAt cursor would freeze it. Tiny table: full refresh only.
parent="services",
inject_parent_key="serviceId",
+ skip_parent_on_bad_request=True,
),
"env_groups": RenderEndpointConfig(
name="env_groups",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/render/tests/test_render.py b/products/warehouse_sources/backend/temporal/data_imports/sources/render/tests/test_render.py
index 86d7ed0cf49c..cdafa27c3ba6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/render/tests/test_render.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/render/tests/test_render.py
@@ -280,6 +280,30 @@ class TestFanOut:
assert batches == [[{"serviceId": "srv-2", "id": "dep-2"}]]
+ def test_custom_domains_400_for_unsupported_service_is_skipped(self) -> None:
+ # Render 400s /custom-domains for service types that can't have them (cron jobs, etc.);
+ # skip that parent instead of failing the whole sync.
+ batches, _, _ = _rows(
+ "custom_domains",
+ [
+ self.SERVICES_PAGE,
+ _response({"message": "Bad Request"}, status=400),
+ [{"customDomain": {"id": "dom-2"}}],
+ ],
+ )
+
+ assert batches == [[{"serviceId": "srv-2", "id": "dom-2"}]]
+
+ def test_400_still_fails_for_endpoints_without_skip_flag(self) -> None:
+ with pytest.raises(requests.HTTPError):
+ _rows(
+ "deploys",
+ [
+ self.SERVICES_PAGE,
+ _response({"message": "Bad Request"}, status=400),
+ ],
+ )
+
def test_resume_skips_parents_before_bookmark_and_seeds_cursor(self) -> None:
batches, session, _ = _rows(
"deploys",