: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-imports): treat custom REST source 400 as non-retryable (#71855)
Tom Owersbded6cb87eaa
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.pyindex 00bb9e9e953d..7e9b77aeda1a 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@@ -759,6 +759,10 @@ class CustomSource(SimpleSource[CustomSourceConfig]):return {"401 Client Error": "The upstream API rejected the request with HTTP 401. Check that the configured auth credentials are correct.","403 Client Error": "The upstream API rejected the request with HTTP 403. The configured credentials may lack the required permissions.",+ # The request shape — path, query params, and the incremental cursor's wire format —+ # is entirely manifest-driven, so a 400 is deterministic: the same request recurs on+ # every retry. Stop retrying and point at the config the user can actually change.+ "400 Client Error": "The upstream API rejected the request with HTTP 400. Check the resource's path, query params, and — for an incremental sync — the cursor's date format 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.pyindex 2a515ceca4e4..b2224641aa1a 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@@ -1735,6 +1735,21 @@ class TestCustomSourceNonRetryableErrors(SimpleTestCase):assert "not found in config" in str(ctx.exception)assert "not found in config" in CustomSource().get_non_retryable_errors()+ def test_http_400_bad_request_is_classified_non_retryable(self):+ # A custom source's request is entirely manifest-driven, so a 400 is deterministic —+ # retrying can't fix it. Build the real requests HTTPError message the REST client+ # raises via raise_for_status(), so this breaks if the matched substring drifts from+ # what requests actually produces. The URL is a placeholder, never a real customer host.+ response = Response()+ response.status_code = 400+ response.reason = "Bad Request"+ response.url = "https://api.example.com/opportunities?filter=2026-07-14T03:25:15.495000+00:00"+ with self.assertRaises(requests.exceptions.HTTPError) as ctx:+ response.raise_for_status()++ non_retryable = CustomSource().get_non_retryable_errors()+ assert any(key in str(ctx.exception) 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