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 reporting transient DNS blips in custom source (#126712)

Tom Owers3988796f7845
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 813fde6189e9..54b3f35989f0 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
@@ -39,7 +39,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.htt
make_tracked_session,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http.transport import _NoRedirectSession
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import _is_host_safe
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import (
+ TEMPORARY_HOST_RESOLUTION_PREFIX,
+ _is_host_safe,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
RESTAPIConfig,
@@ -1083,6 +1086,14 @@ class CustomSource(SimpleSource[CustomSourceConfig]):
"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 get_retryable_errors(self) -> set[str]:
+ # `_is_host_safe` raises this when the resolver itself failed to answer (a DNS blip),
+ # as opposed to answering that the host doesn't exist — that permanent case is
+ # "Couldn't resolve the host" above. `validate_manifest_urls` folds it into
+ # ManifestValidationError, which loses the original TemporaryHostResolutionError type,
+ # so this can't be caught by isinstance the way other sources' host checks are.
+ return {TEMPORARY_HOST_RESOLUTION_PREFIX}
+
def _assemble_manifest(self, config: CustomSourceConfig) -> dict[str, Any]:
"""Parse the stored manifest and rejoin it with the auth credentials.
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 fdedf7808ecb..10f3b0efbcc9 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
@@ -1979,6 +1979,27 @@ class TestCustomSourceNonRetryableErrors(SimpleTestCase):
non_retryable = CustomSource().get_non_retryable_errors()
assert any(key in err for key in non_retryable)
+ def test_temporary_dns_resolution_failure_message_is_classified_retryable(self):
+ # `_is_host_safe` raises this message when the resolver itself fails to answer (a DNS
+ # blip), distinct from the permanent "Couldn't resolve the host" case above. It must stay
+ # out of get_non_retryable_errors and be matched by get_retryable_errors, so the caller
+ # treats it as transient and re-raises for Temporal to retry instead of reporting it.
+ with patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.custom.source._is_host_safe",
+ return_value=(
+ False,
+ "Temporary failure resolving the host 'api.example.com'. Try again in a moment.",
+ ),
+ ):
+ 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 not any(key in err for key in non_retryable)
+ retryable = CustomSource().get_retryable_errors()
+ assert any(key in err for key in 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