: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(supabase): stop auto-syncing dated realtime message partitions (#95755)
Tom Owersf6cd051f90a2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/source.pyindex 2028a834da4c..ca9429b5823c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/source.py@@ -89,6 +89,11 @@ _SUPABASE_REALTIME_PARTITION_MESSAGE = ("the sync.")+# The same partitions as they arrive from discovery, where the schema and table names come+# separately and the display name carries the schema only for a multi-schema source.+_REALTIME_SCHEMA = "realtime"+_REALTIME_MESSAGES_TABLE_PREFIX = "messages_"+# Supabase Vault's schema: its `decrypted_secrets` view decrypts every stored secret on read,# so sync-enabling it by default would copy a secrets vault into the warehouse._VAULT_SCHEMA = "vault"@@ -133,8 +138,12 @@ class SupabaseSource(PostgresSource):# filtered because scheduled discovery reconciles stored rows against this listing# and would disable a vault sync a user deliberately opted into; default-off is# honored by the picker, one-shot setup, and auto-sync of newly discovered schemas.+ # Realtime's dated message partitions default off for the same reason auto-sync+ # exists: each day brings a new one, and Supabase drops it again days later, so an+ # automatically enabled partition fails for good (see+ # `_SUPABASE_REALTIME_PARTITION_MESSAGE`).for schema in schemas:- if schema.source_schema == _VAULT_SCHEMA:+ if schema.source_schema == _VAULT_SCHEMA or self._is_realtime_message_partition(schema):schema.should_sync_default = False# Supabase tables carry arbitrary user columns, so the first discovered candidate@@ -146,6 +155,12 @@ class SupabaseSource(PostgresSource):return schemas+ @staticmethod+ def _is_realtime_message_partition(schema: SourceSchema) -> bool:+ return schema.source_schema == _REALTIME_SCHEMA and (schema.source_table_name or "").startswith(+ _REALTIME_MESSAGES_TABLE_PREFIX+ )+@staticmethoddef _adjust_field(field: _SourceField) -> _SourceField:if isinstance(field, SourceFieldInputConfig) and field.name == "host":diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/test_supabase_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/test_supabase_source.pyindex 8cac2e8554a8..581c34d019d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/test_supabase_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/supabase/test_supabase_source.py@@ -195,6 +195,29 @@ def test_vault_tables_are_never_sync_enabled_by_default():}+ "name,source_schema,expected_default",+ [+ ("realtime.messages_2020_01_01", "realtime", False),+ # A single-schema source lists the table unqualified, so the schema and table fields+ # are the only reliable signal.+ ("messages_2020_01_01", "realtime", False),+ # The partitioned parent and the rest of the schema keep their normal default.+ ("realtime.messages", "realtime", True),+ ("realtime.subscription", "realtime", True),+ # A customer table that happens to share the prefix is not a Realtime partition.+ ("public.messages_archive", "public", True),+ ],+)+def test_dated_realtime_partitions_are_never_sync_enabled_by_default(name, source_schema, expected_default):+ # Supabase drops each day's realtime.messages partition, so a partition enabled by auto-sync+ # of newly discovered tables fails for good within days. The partitions stay listed for the+ # same reason the vault tables do.+ schemas = _get_schemas([_discovered_schema(name, source_schema)])++ assert schemas[0].should_sync_default is expected_default++def test_update_tracking_column_leads_the_incremental_candidates():# Discovery lists candidates in column ordinal order, and several surfaces default to the# first one — without ranking, a table like (priority, dateOfBirth, updated_at) gets a