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): stop retrying resend domains sync on account-level 400 (#74730)

Tom Owers3df4eacdba9e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
index ea10ae256e31..3574515e17a3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
@@ -232,6 +232,16 @@ Either way, the connection needs **full access** so the following resources can
"account can't access the Broadcasts API — enable Broadcasts in Resend and grant the API key full "
"access, or unselect the Broadcasts table to keep syncing your other Resend data."
),
+ # Resend rejects the well-formed list request with a 400 when the connected account can't
+ # access the Domains API (seen in production for accounts without domain management
+ # enabled). Retrying the identical request can't fix an account-level restriction. Scope
+ # the match to the domains path so a 400 from another endpoint (which could be our bug)
+ # stays retryable and visible.
+ "400 Client Error: Bad Request for url: https://api.resend.com/domains": (
+ "Resend rejected the request to sync your Domains. This usually means the connected Resend "
+ "account can't access the Domains API — grant the API key full access, or unselect the Domains "
+ "table to keep syncing your other Resend data."
+ ),
}
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[ResendResumeConfig]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
index 35d403de3a46..2ad7602ba6bd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
@@ -100,6 +100,24 @@ class TestResendSource:
else:
assert not matched
+ @parameterized.expand(
+ [
+ ("domains_matches", "https://api.resend.com/domains", True),
+ ("other_endpoint_stays_retryable", "https://api.resend.com/emails", False),
+ ]
+ )
+ def test_domains_bad_request_retryability(self, _name: str, url: str, should_match: bool):
+ errors = self.source.get_non_retryable_errors()
+ raised = f"400 Client Error: Bad Request for url: {url}"
+
+ matched = [message for key, message in errors.items() if key in raised]
+
+ if should_match:
+ assert len(matched) == 1
+ assert matched[0] is not None and "Domains" in matched[0]
+ else:
+ assert not matched
+
def test_get_schemas(self):
schemas = self.source.get_schemas(self.config, self.team_id)