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 invalid identifier errors as non-retryable (#63725)

Tom Owers622bc37c7981
diff --git a/posthog/temporal/data_imports/sources/snowflake/source.py b/posthog/temporal/data_imports/sources/snowflake/source.py
index 9b2ffba6b67b..a4d27adab185 100644
--- a/posthog/temporal/data_imports/sources/snowflake/source.py
+++ b/posthog/temporal/data_imports/sources/snowflake/source.py
@@ -193,6 +193,12 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):
"Duo Security authentication is denied": "Snowflake rejected the login because multi-factor authentication (Duo Security) is enforced for this user. Automated syncs can't answer an MFA prompt — connect with a service user that uses key-pair authentication or is exempt from MFA.",
"invalid credentials": "Snowflake authentication failed. Please check your username, password, and account details.",
"authentication failed": "Snowflake authentication failed. Please check your username, password, and account details.",
+ # Snowflake error 000904 (42000): the table or view we select from references a column
+ # that no longer exists — typically a stale view definition or a column dropped/renamed
+ # in the source schema. We only run `SELECT ... FROM IDENTIFIER(%s)`, so the bad identifier
+ # 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.",
# 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 c448e206455e..91c49bb28d6e 100644
--- a/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py
+++ b/posthog/temporal/data_imports/sources/snowflake/tests/test_snowflake.py
@@ -591,6 +591,21 @@ class TestSnowflakeSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"No-active-warehouse error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "invalid identifier 'PROPERTIES_HS_DATE_ENTERED_2698018010'",
+ # The real shape from production: the error code and identifier vary, but the
+ # "invalid identifier" substring is stable. Newlines are normalized to spaces upstream.
+ "000904 (42000): 01c5127d-0107-1b91-0002-d576110f85ca: SQL compilation error: error line 64 at position 36 "
+ "invalid identifier 'PROPERTIES_HS_DATE_ENTERED_2698018010'",
+ ],
+ )
+ def test_invalid_identifier_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"Invalid-identifier error should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[