: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): treat TOTP-enforced MFA login as non-retryable (#105612)
Tom Owersee7f07675be0
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 b714111ab030..f67c5ab29705 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@@ -98,6 +98,10 @@ SnowflakeErrors = {# "check all connection details" message, so people re-enter correct credentials repeatedly."Duo Security authentication is denied": _MFA_ENFORCED_MESSAGE.format(action="try again."),"MFA authentication is required": _MFA_ENFORCED_MESSAGE.format(action="try again."),+ # Snowflake error 250001 (08001): the account enforces TOTP-based MFA instead of Duo, so the+ # connector's password-only login is rejected asking for a live TOTP passcode. A distinct phrase+ # from the "MFA authentication is required" case above.+ "MFA with TOTP is required": _MFA_ENFORCED_MESSAGE.format(action="try again."),}@@ -289,6 +293,11 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig], ResumableSource[Snowflak# retrying never succeeds. The codes and host in the message are volatile, so we match the# stable phrase."Multi-factor authentication is required for this account": "Snowflake rejected the login because this account requires multi-factor authentication enrollment. Automated syncs can't complete MFA — connect with a service user that uses key-pair authentication or is exempt from MFA, then resync.",+ # Snowflake error 250001 (08001): the account enforces TOTP-based MFA, so a password-only+ # login is rejected asking for a live TOTP passcode. An unattended sync can't answer that+ # prompt, so retrying never succeeds. Distinct phrase from "MFA authentication is+ # required" above, so it needs its own entry.+ "MFA with TOTP is required": _MFA_ENFORCED_MESSAGE.format(action="resync."),"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 250001 (08001): the supplied username or password is wrong, so thediff --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 d23314525756..f6f7bcf60588 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@@ -909,6 +909,21 @@ class TestSnowflakeSourceNonRetryableErrors:is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())assert is_non_retryable, f"MFA-enrollment error should be non-retryable: {error_msg}"+ @pytest.mark.parametrize(+ "error_msg",+ [+ "MFA with TOTP is required",+ # The real shape from production: codes + host vary, but the TOTP substring is stable.+ "250001 (08001): None: Failed to connect to DB: acme-xy123.snowflakecomputing.com:443. "+ "Failed to authenticate: MFA with TOTP is required. To authenticate, provide both your "+ "password and a current TOTP passcode.",+ ],+ )+ def test_mfa_totp_required_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"MFA-TOTP-required error should be non-retryable: {error_msg}"+def test_mfa_required_maps_to_a_message_instead_of_the_raw_snowflake_text(self, source):# The raw text carries the account host and vendor codes, so the entry must supply its own# message rather than letting the failure surface unchanged.@@ -1282,6 +1297,9 @@ class TestSnowflakeValidateCredentials:"Duo Security authentication is denied.","250001 (08001): None: Failed to connect to DB: acme-xy123.snowflakecomputing.com:443. ""MFA authentication is required.",+ "250001 (08001): None: Failed to connect to DB: acme-xy123.snowflakecomputing.com:443. "+ "Failed to authenticate: MFA with TOTP is required. To authenticate, provide both your "+ "password and a current TOTP passcode.",],)def test_mfa_enforced_login_returns_friendly_message_without_capture(self, source, raw_message):