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(warehouse_sources): stop retrying custom source syncs on unresolvable host (#73363)

Tom Owers6ea8f2062452
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
index 58c99758d57b..3df0f608ce7b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
@@ -900,6 +900,12 @@ class CustomSource(SimpleSource[CustomSourceConfig]):
# stop and point at the config the user can change. Matches the stable prefix
# RESTClientNonRetryableError uses, not the variable URL that follows.
"Non-JSON response from": "The upstream API returned a non-JSON response (for example an HTML or plain-text error page) instead of data. Check that the resource's URL and path in the manifest point at a JSON API endpoint and that any required authentication is configured, then try again.",
+ # `_is_host_safe` raises this when a manifest's base_url, token_url, or resource
+ # host doesn't resolve via DNS — a hostname the customer typed wrong or a host
+ # that's no longer publicly reachable. Deterministic and permanent until the
+ # manifest is edited, so stop retrying. Match the stable prefix, not the
+ # customer's hostname that follows it.
+ "Couldn't resolve the host": "A host in the manifest (base_url, token_url, or a resource's URL) could not be resolved via DNS. Check that it's spelled correctly and reachable from the public internet, then try again.",
}
def _assemble_manifest(self, config: CustomSourceConfig) -> dict[str, Any]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
index 0d96da342a75..bb506408d82d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
@@ -1791,6 +1791,26 @@ class TestCustomSourceNonRetryableErrors(SimpleTestCase):
non_retryable = CustomSource().get_non_retryable_errors()
assert any(key in str(error) for key in non_retryable)
+ def test_dns_resolution_failure_message_is_classified_non_retryable(self):
+ # `_is_host_safe` raises this exact message when a manifest's base_url doesn't
+ # resolve via DNS — a permanent, deterministic failure until the manifest is
+ # edited. Build the real message `validate_manifest_urls` raises (prefix +
+ # `_is_host_safe`'s wording) so this breaks if either side's wording drifts
+ # from the classifier's key.
+ with patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.custom.source._is_host_safe",
+ return_value=(
+ False,
+ "Couldn't resolve the host 'api.example.com'. Check that it's spelled correctly and reachable from the public internet.",
+ ),
+ ):
+ ok, err = validate_manifest_urls(_minimal_manifest(), team_id=999)
+
+ assert not ok
+ assert err is not None
+ non_retryable = CustomSource().get_non_retryable_errors()
+ assert any(key in err for key in non_retryable)
+
@parameterized.expand(["invalid_client", "invalid_grant"])
def test_oauth2_permanent_errors_are_classified_non_retryable(self, error_code):
# A permanent OAuth2 token rejection (invalid_client / invalid_grant) surfaces the