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 missing current database as non-retryable (#67128)

Tom Owersb0f654e5368f
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.py
index e7d4ff25afea..8f2c667bc1cd 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
@@ -205,6 +205,13 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):
# warehouse is missing/suspended or the role lacks USAGE on it — it just leaves the session
# warehouse unset. Retrying can never succeed until the customer fixes the grant or warehouse.
"No active warehouse selected in the current session": "No active warehouse is available for this connection. Check that the configured warehouse exists, is running, and that the connecting role has USAGE on it, then resync.",
+ # Snowflake error 090105 (22000): the session has no current database, so the first query
+ # that references an unqualified object (our `information_schema` listing query) fails. The
+ # connector doesn't fail at connect time when the configured database is missing or the role
+ # lacks USAGE on it — it just leaves the session database unset. Retrying can never succeed
+ # until the customer fixes the database name or the grant. The query id is volatile, so we
+ # match the stable phrase.
+ "This session does not have a current database": "No database is available for this connection. Check that the configured database exists and that the connecting role has USAGE on it, then resync.",
"404 Not Found": None,
"Your free trial has ended": "Your Snowflake account has been suspended or trial has ended. Please check your account status.",
"Your account is suspended due to lack of payment method": "Your Snowflake account has been suspended or trial has ended. Please check your account status.",
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.py
index ec6c0691aa7c..74c48089f4bf 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
@@ -682,6 +682,20 @@ 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",
+ [
+ "This session does not have a current database",
+ # The real shape from production: the query id varies, but the substring is stable.
+ "090105 (22000): 01c56677-0108-abbc-0090-000000000000: Cannot perform SELECT. This session does "
+ "not have a current database. Call 'USE DATABASE', or use a qualified name.",
+ ],
+ )
+ def test_no_current_database_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"No-current-database error should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[