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(data-warehouse): explain the error when a table lacks a usable primary key (#70264)

Tom Owers0389d5d98ec3
diff --git a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
index 04f39702f222..13f64a73f309 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
@@ -100,8 +100,15 @@ Any_Source_Errors: dict[str, str | None] = {
"(private key, passphrase, or username and password) on the source's SSH tunnel "
"configuration, then re-enable the sync."
),
- "Primary key required for incremental syncs": None,
- "The primary keys for this table are not unique": None,
+ "Primary key required for incremental syncs": (
+ "This table needs a primary key to sync incrementally, but none is set. Choose a primary key "
+ "for the table in its sync settings, or switch it to full table replication, then re-enable the sync."
+ ),
+ "The primary keys for this table are not unique": (
+ "The primary key set for this table isn't unique, so incremental syncing can't reliably match "
+ "rows to update. Choose a unique primary key in the table's sync settings, or switch it to full "
+ "table replication, then re-enable the sync."
+ ),
"Integration matching query does not exist": "The connected account for this source is no longer available — it may have been disconnected. Please reconnect the source's account.",
# A fatal TLS alert from the remote host (raised in the shared HTTP transport for every
# REST-based source). The server refused the handshake, which is deterministic for a given
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
index 6111aeaf9535..5109319e9425 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
@@ -169,7 +169,11 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"Can't connect to MySQL server on": None,
- "No primary key defined for table": None,
+ "No primary key defined for table": (
+ "This table needs a primary key to sync incrementally, but none is set. Choose a primary "
+ "key for the table in its sync settings, or switch it to full table replication, then "
+ "re-enable the sync."
+ ),
# MySQL/MariaDB error 1045 (ER_ACCESS_DENIED_ERROR): the user/password (or the
# user's host grant) is wrong. Surface it as an auth failure — mirroring the Postgres
# source — so the user fixes credentials instead of the generic "check connection
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.py
index 5d9941e28539..9ee82f4b70ad 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
@@ -349,7 +349,11 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"and password configured for this source match what the proxy expects, then "
"re-enable the sync."
),
- "No primary key defined for table": None,
+ "No primary key defined for table": (
+ "This table needs a primary key to sync incrementally, but none is set. Choose a primary "
+ "key for the table in its sync settings, or switch it to full table replication, then "
+ "re-enable the sync."
+ ),
"failed: timeout expired": None,
# NOTE: "SSL connection has been closed unexpectedly" is intentionally NOT listed here.
# It denotes an established SSL connection being dropped on connect or mid-stream (idle
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/source.py
index f38786e931a7..9443b2e10339 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/source.py
@@ -141,7 +141,11 @@ class RedshiftSource(SQLSource[RedshiftSourceConfig], SSHTunnelMixin, ValidateDa
"could not translate host name": None,
"timeout expired connection to server at": None,
"password authentication failed for user": None,
- "No primary key defined for table": None,
+ "No primary key defined for table": (
+ "This table needs a primary key to sync incrementally, but none is set. Choose a primary "
+ "key for the table in its sync settings, or switch it to full table replication, then "
+ "re-enable the sync."
+ ),
"failed: timeout expired": None,
"SSL connection has been closed unexpectedly": None,
"server does not support SSL": None,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
index f1b8f16389d3..28122f8aa17c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py
@@ -2732,7 +2732,7 @@ async def test_postgres_duplicate_primary_key(team, postgres_config, postgres_co
assert job.status == ExternalDataJob.Status.FAILED
assert job.latest_error is not None
assert (
- "The primary keys for this table are not unique. We can't sync incrementally until the table has a unique primary key"
+ "The primary key set for this table isn't unique, so incremental syncing can't reliably match rows to update"
in job.latest_error
)