: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
feat(data-warehouse): send default_team_id when provisioning duckgres (#68182)
Benjamin Knofe-Vider699839cb07fe
diff --git a/products/data_warehouse/backend/presentation/views/managed_warehouse.py b/products/data_warehouse/backend/presentation/views/managed_warehouse.pyindex 2d1db132d9e3..d5fea9dc655c 100644--- a/products/data_warehouse/backend/presentation/views/managed_warehouse.py+++ b/products/data_warehouse/backend/presentation/views/managed_warehouse.py@@ -208,6 +208,12 @@ def provision("/provision",json_body={"database_name": database_name,+ # The provisioning team is the warehouse's default team: duckgres pins it so+ # queries without an explicit team resolve to this environment's tables. It's+ # required — duckgres denies a provision without it. In-product this is the+ # calling (currently active) team; in the Django admin it's the mandatory team+ # field on the provision form.+ "default_team_id": team_id,"ducklake": {"enabled": True},"metadata_store": {"type": "cnpg-shard"},"data_store": {"type": "s3bucket"},diff --git a/products/data_warehouse/backend/tests/api/test_managed_warehouse.py b/products/data_warehouse/backend/tests/api/test_managed_warehouse.pyindex 8dc05930007b..921e40509ce7 100644--- a/products/data_warehouse/backend/tests/api/test_managed_warehouse.py+++ b/products/data_warehouse/backend/tests/api/test_managed_warehouse.py@@ -56,6 +56,25 @@ def test_provision_persists_duckgres_server_on_success(mock_request: MagicMock)assert server.bucket_region is None+@override_settings(CLOUD_DEPLOYMENT="US", DUCKGRES_PG_PORT=5432)+@patch("products.data_warehouse.backend.presentation.views.managed_warehouse._request")+def test_provision_sends_default_team_id_to_control_plane(mock_request: MagicMock) -> None:+ # duckgres denies a provision without a default team, so the provisioning team must be+ # forwarded as default_team_id in the outbound body.+ org = Organization.objects.create(name="Org")+ team = Team.objects.create(organization=org)+ mock_request.return_value = Response(+ {"status": "provisioning started", "org": str(org.id), "username": "root", "password": "secret"},+ status=202,+ )++ managed_warehouse.provision(org.id, "my-warehouse", team.id, "events")++ json_body = mock_request.call_args.kwargs["json_body"]+ assert json_body["default_team_id"] == team.id++@pytest.mark.django_db@override_settings(CLOUD_DEPLOYMENT="US", DUCKGRES_PG_PORT=5432)@patch("products.data_warehouse.backend.presentation.views.managed_warehouse._request")