: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(snowflake): classify chunk-download HTTP 400 as retryable noise (#73694)
Tom Owersab430290ba7f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.pyindex 173443acecf5..440e344616c7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py@@ -302,6 +302,19 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):"HTTP 403: Forbidden": "Snowflake refused the request with an HTTP 403 (forbidden). This usually means a network policy or firewall on your account is blocking PostHog's access, or your role's access to the data was revoked. Check your Snowflake network access rules and role grants, then resync.",}+ def get_retryable_errors(self) -> set[str]:+ return {+ # Snowflake connector error 290400 (ER_HTTP_GENERAL_ERROR + 400): downloading a query+ # result chunk got HTTP 400, which the connector's own `is_retryable_http_code` already+ # retries with backoff before re-raising the plain `BadRequest` once its download retry+ # budget is exhausted (`result_batch.py::_download`). Unlike the persistent-403 case+ # above, every Temporal-level retry of `get_rows` opens a fresh connection and re-executes+ # the query from scratch, getting a brand new set of chunk URLs — a stale one from the+ # previous attempt doesn't carry over. Self-recovering, so keep retrying instead of+ # stopping the sync. The errno prefix is volatile, so we match the stable status text.+ "HTTP 400: Bad Request",+ }+def reconcile_schema_metadata(self,source: "ExternalDataSource",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.pyindex 6b0c1c8480ec..473794f124a8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py@@ -886,6 +886,29 @@ class TestSnowflakeSourceNonRetryableErrors:assert not is_non_retryable, f"Error should remain retryable: {error_msg}"+class TestSnowflakeSourceRetryableErrors:+ @pytest.fixture+ def source(self):+ return SnowflakeSource()++ @pytest.mark.parametrize(+ "error_msg",+ [+ # The real shape from production: the connector's BadRequest formats as "<errno>: <errno>: <msg>".+ "290400: 290400: HTTP 400: Bad Request",+ "HTTP 400: Bad Request",+ ],+ )+ def test_chunk_download_bad_request_is_retryable(self, source, error_msg):+ # Downloading a query result chunk got HTTP 400, and the connector's own retry budget+ # (`result_batch.py::_download`) was already exhausted before `BadRequest` re-raised. Without+ # this classification `_handle_import_error` logs it at `exception` on every occurrence,+ # flooding error tracking with a self-recovering failure.+ retryable = source.get_retryable_errors()+ is_retryable = any(pattern in error_msg for pattern in retryable)+ assert is_retryable, f"Chunk-download bad-request error should be classified retryable: {error_msg}"++class TestSnowflakeValidateCredentials:@pytest.fixturedef source(self):