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(snowflake): treat network policy IP block as non-retryable (#63691)

Tom Owersce880d232082
diff --git a/posthog/temporal/data_imports/sources/snowflake/source.py b/posthog/temporal/data_imports/sources/snowflake/source.py
index 08e86e848b6b..59fd95fffbf7 100644
--- a/posthog/temporal/data_imports/sources/snowflake/source.py
+++ b/posthog/temporal/data_imports/sources/snowflake/source.py
@@ -202,6 +202,10 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):
# lives in the customer's object, not in our SQL. Retrying can't fix it until they repair
# the object or reconfigure the synced columns.
"invalid identifier": "A Snowflake table or view you're syncing references a column that no longer exists (for example a stale view definition, or a column that was dropped or renamed). Please fix the table or view in Snowflake, or reconfigure the columns selected for this table, then resync.",
+ # Snowflake error 250001 (08001): a network policy (IP allowlist) on the customer's account
+ # rejects the connection because PostHog's egress IP isn't permitted. Retrying can never
+ # succeed until their admin allowlists our IPs, so stop retrying and surface what to do.
+ "is not allowed to access Snowflake": "Snowflake rejected the connection because a network policy (IP allowlist) on your account does not permit PostHog's IP address. Ask your Snowflake administrator to add PostHog's egress IP addresses to the network policy allowlist, then resync.",
# Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. a narrower NUMBER widened
# to a larger NUMBER/BIGINT) after the destination table was created with the
diff --git a/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py b/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py
index b69d11c2bdff..2bd553d66393 100644
--- a/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py
+++ b/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py
@@ -620,6 +620,23 @@ class TestSnowflakeSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"Expired-password error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "is not allowed to access Snowflake",
+ # The real shape from production: codes, IP/token, host, and help URL all vary,
+ # but the network-policy substring is stable.
+ "250001 (08001): None: Failed to connect to DB: ihoilnv-wd33458.snowflakecomputing.com:443. "
+ "Incoming request with IP/Token 44.208.188.173 is not allowed to access Snowflake. "
+ "Contact your account administrator. For more information about this error, go to "
+ "https://community.snowflake.com/s/ip-xxxxxxxxxxxx-is-not-allowed-to-access.",
+ ],
+ )
+ def test_network_policy_block_is_non_retryable(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
+ assert is_non_retryable, f"Network-policy block should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[