: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(redshift): stop reporting svv_table_info permission errors as exceptions (#63914)
Tom Owers930d1dbc0a35
diff --git a/posthog/temporal/data_imports/sources/redshift/redshift.py b/posthog/temporal/data_imports/sources/redshift/redshift.pyindex b9a3f40f649f..9d8099f82f9c 100644--- a/posthog/temporal/data_imports/sources/redshift/redshift.py+++ b/posthog/temporal/data_imports/sources/redshift/redshift.py@@ -863,6 +863,13 @@ class RedshiftImplementation(SQLSourceImplementation[RedshiftSourceConfig, psycoresult = cursor.fetchone()except psycopg.errors.QueryCanceled:raise+ except psycopg.errors.InsufficientPrivilege as e:+ # Some Redshift roles aren't granted access to the `svv_table_info` system view. That's+ # a customer permission-config issue, not an actionable bug — table stats are optional+ # (we fall back to no partitioning), so skip gracefully without reporting the expected,+ # non-actionable error to error tracking. Mirrors `_explain_query`/`get_row_counts`.+ logger.debug(f"fetch_table_stats: no access to svv_table_info, returning None: {e}")+ return Noneexcept Exception as e:capture_exception(e)logger.debug(f"fetch_table_stats: returning None due to error: {e}")diff --git a/posthog/temporal/data_imports/sources/redshift/tests/test_redshift.py b/posthog/temporal/data_imports/sources/redshift/tests/test_redshift.pyindex cc3c7a0c1d08..2a5c8e490929 100644--- a/posthog/temporal/data_imports/sources/redshift/tests/test_redshift.py+++ b/posthog/temporal/data_imports/sources/redshift/tests/test_redshift.py@@ -261,7 +261,20 @@ class TestFetchTableStats:def test_returns_none_on_exception(self, impl, cursor, logger):cursor.execute.side_effect = RuntimeError("boom")- assert impl.fetch_table_stats(cursor, "public", "t", logger) is None+ with patch("posthog.temporal.data_imports.sources.redshift.redshift.capture_exception") as mock_capture:+ assert impl.fetch_table_stats(cursor, "public", "t", logger) is None+ mock_capture.assert_called_once()++ def test_permission_denied_on_svv_table_info_is_not_reported(self, impl, cursor, logger):+ # Some Redshift roles lack SELECT on `svv_table_info`. That's an expected customer+ # permission-config issue — stats are optional, so skip gracefully without reporting the+ # non-actionable error to error tracking (the source of the reported noise).+ cursor.execute.side_effect = psycopg.errors.InsufficientPrivilege(+ "permission denied for relation svv_table_info"+ )+ with patch("posthog.temporal.data_imports.sources.redshift.redshift.capture_exception") as mock_capture:+ assert impl.fetch_table_stats(cursor, "public", "t", logger) is None+ mock_capture.assert_not_called()def test_failed_explain_does_not_poison_real_query(self, impl, logger):# Reproduces the reported incident: EXPLAIN on `svv_table_info` fails (Redshift can't