: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(postgres): stop retrying syncs that hit an invalid uuid value (#115310)
Tom Owersd2dce60d9974
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.pyindex 6f5b0ab11626..abc304c70bd0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py@@ -1368,6 +1368,19 @@ class PostgresSource("wasn't translated to a real NULL. Fix the remote data or the foreign table's column ""type, or remove the foreign table from the sync, then re-enable the sync."),+ # A value that isn't a uuid reached a uuid column (InvalidTextRepresentation, SQLSTATE+ # 22P02). Ordinary tables validate uuid values at write time, so the value comes from the+ # customer's side: a foreign table or a view that casts text to uuid, or a row filter on a+ # uuid column. Row filter validation treats uuid as a plain string, so it accepts any+ # value. No query PostHog builds casts to uuid, and uuid is never an incremental field+ # type. Every retry runs the same statement again. The volatile value is excluded.+ "invalid input syntax for type uuid": (+ "PostgreSQL rejected a value that isn't a valid UUID for a uuid column "+ '("invalid input syntax for type uuid"). If this table has a row filter on a uuid '+ "column, change the filter value to a valid UUID. Otherwise the table is likely a view "+ "or foreign table that converts text to uuid, so fix the data or the column type, or "+ "remove the table from the sync. Then re-enable the sync."+ ),}def get_retryable_errors(self) -> set[str]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.pyindex 9586a05d5409..f47db5c05ad8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py@@ -1759,12 +1759,14 @@ class TestPostgresSourceNonRetryableErrors:'invalid input syntax for type timestamp: "\\N"\nCONTEXT: column "created_at" of foreign table "events"',# Temporal-wrapped message (what the workflow-level check sees) — carries the class name.'InvalidDatetimeFormat: invalid input syntax for type timestamp: "\\N"',+ 'invalid input syntax for type uuid: "not-a-uuid"',+ 'InvalidTextRepresentation: invalid input syntax for type uuid: "not-a-uuid"',],)- def test_fdw_timestamp_mismatch_is_non_retryable(self, source, error_msg):+ def test_column_type_mismatch_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"FDW timestamp mismatch error should be non-retryable: {error_msg}"+ assert is_non_retryable, f"Column type mismatch error should be non-retryable: {error_msg}"def test_fdw_timestamp_mismatch_returns_friendly_message(self, source):non_retryable = source.get_non_retryable_errors()