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(proxy): skip Cloudflare hostname check until DNS resolves (#70458)

Yasen916e32d61710
diff --git a/posthog/api/proxy_record_diagnostics.py b/posthog/api/proxy_record_diagnostics.py
index 5b8234f35200..1d54468a201d 100644
--- a/posthog/api/proxy_record_diagnostics.py
+++ b/posthog/api/proxy_record_diagnostics.py
@@ -203,8 +203,9 @@ def diagnose(record: ProxyRecord) -> DiagnosticReport:
# Healthy — the endpoint works. The only remaining concern is renewal, read from the
# certificate the proxy is actually serving.
checks.append(_check_cert_expiry(record, is_cloudflare=is_cloudflare))
- elif is_cloudflare:
- # Not serving, and provisioned on the Cloudflare path — inspect the custom hostname.
+ elif is_cloudflare and cname_check.status == "passed":
+ # Not serving, DNS resolves, and provisioned on the Cloudflare path — the custom hostname
+ # should exist by now, so inspect it.
cloudflare_check, hostname_info = _check_cloudflare(record)
checks.append(cloudflare_check)
checks.append(_check_caa(record, hostname_info, is_cloudflare=True))
@@ -213,6 +214,28 @@ def diagnose(record: ProxyRecord) -> DiagnosticReport:
else:
checks.append(_skip("http_challenge", "HTTP-01 challenge", "Skipped — no challenge URL available."))
checks.append(_skip("cert_expiry", "Certificate expiry", "Skipped — certificate is not active yet."))
+ elif is_cloudflare:
+ # Cloudflare path, but DNS isn't pointing at us. The custom hostname is validated against
+ # the CNAME, so with DNS broken the hostname lookup can't tell us anything actionable —
+ # whether the proxy was never provisioned (DNS not yet set) or was provisioned and its DNS
+ # later regressed, the fix is the same: repair the CNAME. Skip the Cloudflare checks and
+ # point at the failed CNAME above rather than asserting a provisioning state we don't know
+ # (the old "we don't have a record of this proxy → Hit Retry" was wrong in both cases).
+ # CAA still matters pre-issuance.
+ checks.append(
+ _skip(
+ "cloudflare",
+ "Cloudflare custom hostname",
+ "Skipped — we can't check the certificate until the CNAME resolves. Fix the DNS record above first.",
+ )
+ )
+ checks.append(_check_caa(record, None, is_cloudflare=True))
+ checks.append(
+ _skip("http_challenge", "HTTP-01 challenge", "Skipped — we can't check this until the CNAME resolves.")
+ )
+ checks.append(
+ _skip("cert_expiry", "Certificate expiry", "Skipped — we can't check this until the CNAME resolves.")
+ )
else:
# Not serving, and provisioned on the legacy path — there is no Cloudflare custom
# hostname by design, so the Cloudflare check would only ever produce a false
diff --git a/posthog/api/test/test_proxy_record_diagnostics.py b/posthog/api/test/test_proxy_record_diagnostics.py
index 776fe528a13d..da6fb154ca45 100644
--- a/posthog/api/test/test_proxy_record_diagnostics.py
+++ b/posthog/api/test/test_proxy_record_diagnostics.py
@@ -384,6 +384,31 @@ class TestDiagnoseOrchestrator(TestCase):
assert cf_check.remediation is not None
self.assertEqual(cf_check.remediation.type, "retry")
+ @patch("posthog.api.proxy_record_diagnostics.requests.post")
+ @patch("posthog.api.proxy_record_diagnostics.get_custom_hostname_by_domain")
+ @patch("posthog.api.proxy_record_diagnostics.dns.resolver.Resolver")
+ def test_cloudflare_unprovisioned_skips_hostname_check_when_dns_absent(self, ResolverMock, get_mock, post_mock):
+ # A Cloudflare-path proxy whose DNS isn't set yet: we only create the custom hostname
+ # after DNS resolves, so a missing hostname here is expected — not a fault. Skip the
+ # check (not fail it), never call the Cloudflare API, and never suggest retry; the
+ # missing CNAME is the real issue. Guards the false "we don't have a record of this
+ # proxy → Hit Retry" that this record's lifecycle would otherwise surface.
+ def resolve_side_effect(name, rdtype):
+ if rdtype == "CNAME":
+ raise dns.resolver.NXDOMAIN()
+ raise dns.resolver.NoAnswer()
+
+ ResolverMock.return_value.resolve.side_effect = resolve_side_effect
+
+ report = diagnostics.diagnose(_record(target=CF_TARGET))
+
+ post_mock.assert_not_called()
+ get_mock.assert_not_called()
+ cf_check = next(c for c in report.checks if c.id == "cloudflare")
+ self.assertEqual(cf_check.status, "skipped")
+ self.assertFalse(any(c.remediation and c.remediation.type == "retry" for c in report.checks))
+ self.assertEqual(report.summary.primary_issue, "cname")
+
@patch("posthog.api.proxy_record_diagnostics.requests.get")
@patch("posthog.api.proxy_record_diagnostics.requests.post")
@patch("posthog.api.proxy_record_diagnostics.get_custom_hostname_by_domain")