: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(data-warehouse): Allow rotating MongoDB password (#82019)
Luke Belton2bd94f70ecce
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.pyindex 4e8b88b51980..a5786f6f40d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py@@ -314,7 +314,9 @@ class MongoDBSource(SimpleSource[MongoDBSourceConfig], ValidateDatabaseHostMixinSourceFieldInputConfig(name="connection_string",label="Connection String",- type=SourceFieldInputConfigType.TEXT,+ # The connection string is this source's only credential, so `password` keeps+ # it editable on update for rotation.+ type=SourceFieldInputConfigType.PASSWORD,required=True,placeholder="mongodb://username:password@host:port/database?authSource=admin&tls=true",secret=True,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_connection_string_fields.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_connection_string_fields.pynew file mode 100644index 000000000000..ea9676ad4431--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_connection_string_fields.py@@ -0,0 +1,42 @@+from posthog.schema import SourceFieldInputConfig, SourceFieldInputConfigType++from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry++# TEXT connection strings only prefill the credential fields the connection uses, so the edit form+# hides them. PASSWORD ones are the credential itself, so the edit form keeps them editable.+_EXPECTED_TYPE_BY_SOURCE = {+ "ClickHouse": SourceFieldInputConfigType.TEXT,+ "MSSQL": SourceFieldInputConfigType.TEXT,+ "MongoDB": SourceFieldInputConfigType.PASSWORD,+ "Neon": SourceFieldInputConfigType.TEXT,+ "PlanetScalePostgres": SourceFieldInputConfigType.TEXT,+ "Postgres": SourceFieldInputConfigType.TEXT,+ "Redshift": SourceFieldInputConfigType.TEXT,+ "Snowflake": SourceFieldInputConfigType.TEXT,+ "Supabase": SourceFieldInputConfigType.TEXT,+}+++def test_connection_string_field_type_matches_credential_role():+ for source_type, source in SourceRegistry.get_all_sources().items():+ connection_string = next(+ (+ f+ for f in source.get_source_config.fields+ if isinstance(f, SourceFieldInputConfig) and f.name == "connection_string"+ ),+ None,+ )+ if connection_string is None:+ continue++ expected_type = _EXPECTED_TYPE_BY_SOURCE.get(str(source_type))+ assert expected_type is not None, (+ f"{source_type} declares a connection_string but is missing from _EXPECTED_TYPE_BY_SOURCE. "+ f"Add it as PASSWORD if the connection string is the whole credential (so it stays editable "+ f"for rotation), or TEXT if it only prefills other credential fields."+ )+ assert connection_string.type == expected_type, (+ f"{source_type} declares connection_string as {connection_string.type}, expected {expected_type}. "+ f"PASSWORD stays editable on update for rotation, TEXT is hidden there."+ )