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(custom): stop retrying a proxy-rejected (407) request (#83504)

Tom Owersfac17f28e82c
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 e937a1d41b61..ec09b6ef753e 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
@@ -884,6 +884,13 @@ class CustomSource(SimpleSource[CustomSourceConfig]):
# manifest-driven, so the 404 recurs on every retry — stop and point at the config.
# The message omits the URL, which carries the customer's hostname.
"404 Client Error": "The upstream API returned HTTP 404 Not Found. Check that the base URL and the resource's path in the manifest are correct and that the endpoint exists, then try again.",
+ # A network proxy rejected the request before it reached the upstream API. On PostHog
+ # Cloud this is the egress proxy refusing a URL it isn't allowed to reach (a private or
+ # internal address); it can also be an upstream proxy in front of the customer's API
+ # demanding credentials. The manifest-driven request recurs identically on every retry,
+ # so stop and point at the manifest URLs. The message omits the URL, which carries the
+ # customer's hostname.
+ "407 Client Error": "A network proxy rejected the request before it reached the upstream API (HTTP 407). This usually means a URL in the manifest points at an address PostHog can't reach (for example a private or internal address), or the API sits behind a proxy that needs credentials. Check the URLs in the manifest, then try again.",
# A schema points to a resource the manifest no longer defines (renamed or removed
# in an edit while the table's sync stayed scheduled). Permanent until the config is
# fixed — match the stable suffix, not the variable resource name in the message.
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 d156f0a9e7ee..7a9df96036c7 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
@@ -1781,6 +1781,25 @@ class TestCustomSourceNonRetryableErrors(SimpleTestCase):
non_retryable = CustomSource().get_non_retryable_errors()
assert any(key in str(ctx.exception) for key in non_retryable)
+ def test_http_407_proxy_auth_is_classified_non_retryable(self):
+ # A proxy that refuses the request (the egress proxy blocking a disallowed address, or an
+ # upstream proxy needing credentials) returns 407 deterministically, so retrying can't fix
+ # it. Build the real requests HTTPError raise_for_status() produces, so this breaks if the
+ # matched substring drifts. Route through the classifier's message so a regression that
+ # leaves it None (raw driver text) is caught too. The URL is a placeholder.
+ response = Response()
+ response.status_code = 407
+ response.reason = "Proxy Authentication Required"
+ response.url = "https://api.example.com/data"
+ with self.assertRaises(requests.exceptions.HTTPError) as ctx:
+ response.raise_for_status()
+
+ non_retryable = CustomSource().get_non_retryable_errors()
+ matches = [friendly for key, friendly in non_retryable.items() if key in str(ctx.exception)]
+ assert matches
+ assert matches[0] is not None
+ assert "proxy" in matches[0].lower()
+
def test_non_json_response_message_is_classified_non_retryable(self):
# The REST client raises RESTClientNonRetryableError when a configured endpoint
# returns non-JSON (an HTML/plain-text error page) on a 2xx. Build the real error the