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(supabase): point a rejected password at the supabase database password (#114913)

Tom Owersebd2643e80bd
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.py
index b89bafbc8519..9f5b43ea5019 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
@@ -23,6 +23,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
)
from products.warehouse_sources.backend.temporal.data_imports.sources.postgres.source import (
_HOST_UNREACHABLE_ERROR,
+ _INVALID_CREDENTIALS_VALIDATION_ERROR,
PostgresSource,
)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@@ -44,6 +45,13 @@ _SUPABASE_POOLER_USERNAME_AS_HOST_ERROR = (
"the user."
)
+# Supabase has a separate database password, set when the project is created, and people often
+# enter their Supabase account password instead.
+_SUPABASE_INVALID_CREDENTIALS_ERROR = (
+ "The database rejected the username or password. Use your Supabase database password, not your "
+ "account password, or reset it in your project's database settings."
+)
+
def _strip_host_scheme(host: str) -> str:
"""Reduce a pasted value to a bare host: drop any URL scheme, path, and surrounding whitespace."""
@@ -210,4 +218,6 @@ class SupabaseSource(PostgresSource):
success, error = super().validate_credentials(config, team_id, schema_name=schema_name, require_ssl=require_ssl)
if not success and is_direct_host and error == _HOST_UNREACHABLE_ERROR:
return False, _SUPABASE_DIRECT_HOST_IPV4_HINT
+ if not success and error == _INVALID_CREDENTIALS_VALIDATION_ERROR:
+ return False, _SUPABASE_INVALID_CREDENTIALS_ERROR
return success, error
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.py
index 1573d056d20d..1bd76c5f5961 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
@@ -6,6 +6,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas
from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
from products.warehouse_sources.backend.temporal.data_imports.sources.postgres.source import (
_HOST_UNREACHABLE_ERROR,
+ _INVALID_CREDENTIALS_VALIDATION_ERROR,
PostgresSource,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.supabase.source import SupabaseSource
@@ -177,6 +178,27 @@ def test_non_direct_host_failure_uses_postgres_error(host):
assert error == "postgres error"
+ "host",
+ [
+ "aws-0-us-east-1.pooler.supabase.com",
+ "db.abcdefghijklmnop.supabase.co",
+ ],
+)
+def test_rejected_password_points_at_the_supabase_database_password(host):
+ config = mock.MagicMock(host=host)
+
+ with mock.patch.object(
+ PostgresSource, "validate_credentials", return_value=(False, _INVALID_CREDENTIALS_VALIDATION_ERROR)
+ ):
+ success, error = SupabaseSource().validate_credentials(config, team_id=1)
+
+ assert success is False
+ assert error is not None
+ assert "database password" in error
+ assert "ipv4" not in error.lower()
+
+
def _incremental_field(name: str, field_type: IncrementalFieldType) -> IncrementalField:
return {"label": name, "type": field_type, "field": name, "field_type": field_type}