: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(warehouse): support property mapping updates (#89260)
Andrew Ghostuhin989cab596f86
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.pyindex cf6ec0a968a4..15d23fea7044 100644--- a/products/customer_analytics/backend/facade/api.py+++ b/products/customer_analytics/backend/facade/api.py@@ -2014,10 +2014,10 @@ def _expire_stale_running_runs(team_id: int, runs: "Iterable[CustomPropertySyncRdef _create_running_runs(team_id: int, binding: "WarehouseBinding", trigger: str) -> list[Any]:"""Insert a 'running' run for each enabled person/group source on the binding that isn't alreadyrunning. The UI shows these as in-progress and disables the trigger while they exist; the sync and- backfill activities reconcile them to their terminal state (see record_sync_run). Skipping sources- that already have a running run makes this a no-op when a run for the table is already in flight- (coalesced). Returns the source ids a placeholder was created for, so the caller can reconcile them- to FAILED if the workflow start never happens (see ``_fail_created_runs``)."""+ backfill activities reconcile them to their terminal state (see record_sync_run). An existing row+ suppresses only a duplicate placeholder; the binding workflow still receives a signal and opens a+ new row when its follow-up starts. Returns the source ids a placeholder was created for, so the+ caller can reconcile them to FAILED if the workflow start never happens (see ``_fail_created_runs``)."""# A source and a run name the same binding through different columns: a source's schema binding is# the `external_data_schema` FK, a run's is the plain `schema_id`.source_field = "saved_query_id" if binding.is_saved_query else "external_data_schema_id"@@ -2099,7 +2099,7 @@ def _start_backfill(team_id: int, binding: "WarehouseBinding", trigger: str) ->def _start_person_backfill_if_enabled(source: CustomPropertySource) -> None:"""Auto-start a backfill after a person/group source is created/enabled so historical rows populateimmediately rather than waiting for the next warehouse run. Profile sources only (an account source- has its own Celery sync); deduped per table by the workflow id."""+ has its own Celery sync); serialized per table by the workflow id."""binding = _profile_binding(source)if not source.is_enabled or binding is None:return@@ -2107,6 +2107,36 @@ def _start_person_backfill_if_enabled(source: CustomPropertySource) -> None:transaction.on_commit(lambda: _start_backfill(team_id, binding, "backfill"))+def _stamp_profile_source_provenance(source: CustomPropertySource, binding: "WarehouseBinding") -> None:+ """Apply the source's current mapping metadata without waiting for a value-hash change."""+ from products.warehouse_sources.backend.facade.person_property_provenance import ( # noqa: PLC0415+ stamp_person_property_provenance,+ )++ column_property_map = source.column_property_map or {}+ column_descriptions = source.column_descriptions or {}+ property_descriptions = {+ column_property_map[column]: description+ for column, description in column_descriptions.items()+ if column in column_property_map and description+ }+ # Property definitions are keyed by effective project, not team.+ project_id = Team.objects.filter(pk=source.team_id).values_list("project_id", flat=True).first()+ if project_id is None:+ return+ stamp_person_property_provenance(+ team_id=source.team_id,+ project_id=project_id,+ binding=binding,+ source_id=str(source.id),+ definition_id=str(source.definition_id),+ target=source.definition.target_type,+ group_type_index=source.definition.group_type_index,+ property_names=column_property_map.values(),+ property_descriptions=property_descriptions,+ )++def _triggerable_profile_binding(team_id: int, source_id: str) -> "WarehouseBinding | None":"""The warehouse object to act on for a person/group-property trigger, or None when the source isn'ta valid, flag-enabled warehouse-profile source (→ the view returns 400)."""@@ -2213,22 +2243,27 @@ def trigger_person_property_sync(def trigger_person_property_backfill(*, team_id: int, source_id: str, trigger: str = "manual", user_access_control: "UserAccessControl | None" = None) -> bool | None:- """Start a backfill for a profile source's table. Returns True (started), False (already running →- coalesced), or None for an invalid source (→ 400). Requires editor access to the warehouse object- (→ 403)."""+ """Request a backfill for a profile source's table. Returns True when a new visible run starts,+ False when an existing run receives a guaranteed latest-state follow-up, or None for an invalid+ source (→ 400). Requires editor access to the warehouse object (→ 403)."""binding = _triggerable_profile_binding(team_id, source_id)if binding is None:return None_assert_warehouse_editor(team_id, binding, user_access_control)# Placeholder rows before starting, so the activity always finds a running row to reconcile.created_source_ids = _create_running_runs(team_id, binding, trigger)+ # `created_source_ids` covers every enabled source on the binding, not just the one requested —+ # a sibling source can pick up a fresh placeholder while this source's own run was already in+ # flight and merely coalesced. Report 'started' only when the requested source is among them.+ started_new_run = str(source_id) in {str(created_id) for created_id in created_source_ids}from products.warehouse_sources.backend.facade.temporal import ( # noqa: PLC0415WarehouseBindingMissingError,start_person_property_backfill,)try:- return start_person_property_backfill(team_id=team_id, binding=binding, trigger=trigger)+ start_person_property_backfill(team_id=team_id, binding=binding, trigger=trigger)+ return started_new_runexcept WarehouseBindingMissingError:# The warehouse table or view was deleted after the placeholders were created; reconcile them# so the source isn't stuck 'running', and report an invalid source (→ 400) rather than a@@ -2380,27 +2415,60 @@ def create_custom_property_source(return _to_custom_property_source_view(source, user_access_control)def update_custom_property_source(*, team_id: int, source_id: str, fields: dict[str, Any], user_access_control: "UserAccessControl | None" = None) -> contracts.CustomPropertySourceView | None:- """Apply ``fields`` (source_column / key_column / is_enabled) to a team-scoped source. Re-enabling- (is_enabled False→True) resets the failure streak and clears the last error. Returns None (→ 404)- when no source matches."""- source = CustomPropertySource.objects.for_team(team_id).select_related("definition").filter(id=source_id).first()+ """Apply writable fields to a team-scoped source. Re-enabling (is_enabled False→True) resets the+ failure streak and clears the last error. Returns None (→ 404) when no source matches."""+ source = (+ CustomPropertySource.objects.for_team(team_id)+ .select_for_update(of=("self",))+ .select_related("definition")+ .filter(id=source_id)+ .first()+ )if source is None:return None+ fields = dict(fields)+ profile_mapping_fields = {"column_property_map", "column_descriptions"}.intersection(fields)+ if profile_mapping_fields:+ if source.definition.target_type not in _WAREHOUSE_PROFILE_TARGETS:+ if any(fields[field] is not None for field in profile_mapping_fields):+ raise CustomPropertySourceValidationError(+ "An account property source uses saved_query + source_column, not external_data_schema."+ )+ # Account GET responses include these profile-only fields as null. Treating those nulls as+ # absent keeps the writable representation compatible with a GET/PATCH round trip.+ for field in profile_mapping_fields:+ fields.pop(field)+ profile_mapping_fields.clear()+ else:+ validated_map = _validate_column_property_map(fields.get("column_property_map", source.column_property_map))+ if "column_property_map" in fields:+ fields["column_property_map"] = validated_map+ if "column_descriptions" in fields:+ fields["column_descriptions"] = _validate_column_descriptions(+ fields["column_descriptions"], set(validated_map)+ )+ elif "column_property_map" in fields:+ fields["column_descriptions"] = _validate_column_descriptions(+ source.column_descriptions, set(validated_map)+ )reenabling = fields.get("is_enabled") is True and not source.is_enabled+ mapping_changed = "column_property_map" in fields and fields["column_property_map"] != source.column_property_map+ descriptions_changed = (+ "column_descriptions" in fields and fields["column_descriptions"] != source.column_descriptions+ )columns_changed = any(attr in fields and fields[attr] != getattr(source, attr) for attr in ("source_column", "key_column"))- # A profile source's backfill drives a real warehouse run, so any change that will trigger one —- # re-enabling, or changing the mapped columns while it stays enabled — requires the caller's editor- # access on the warehouse object, not account-scope editor alone (matching create). Both routes reach- # _start_person_backfill_if_enabled below via ``reenabling or columns_changed``; ``is_enabled`` here is- # the post-update state that decides whether that helper actually starts a backfill.+ columns_changed = columns_changed or mapping_changed+ # Profile mapping fields always require editor access to the bound warehouse object, including while+ # disabled. Existing re-enable/column changes require it when they will trigger a backfill.will_be_enabled = fields.get("is_enabled", source.is_enabled) is Truebinding = _profile_binding(source)- if binding is not None and will_be_enabled and (reenabling or columns_changed):+ if binding is not None and (profile_mapping_fields or (will_be_enabled and (reenabling or columns_changed))):_assert_warehouse_editor(team_id, binding, user_access_control)for attr, value in fields.items():setattr(source, attr, value)@@ -2408,10 +2476,15 @@ def update_custom_property_source(source.consecutive_failures = 0source.last_sync_error = Nonesource.save()+ # Provenance names the source that writes a property, so only a source that will write claims it.+ # Re-enabling runs a backfill, and that stamps the mapping the source has by then.+ if binding is not None and will_be_enabled and (mapping_changed or descriptions_changed):+ _stamp_profile_source_provenance(source, binding)# Only re-sync on a change that affects what gets written — not on every (possibly no-op) PATCH.if reenabling or columns_changed:_enqueue_initial_account_property_sync(source)- _start_person_backfill_if_enabled(source)+ if will_be_enabled:+ _start_person_backfill_if_enabled(source)return _to_custom_property_source_view(source, user_access_control)diff --git a/products/customer_analytics/backend/facade/custom_property_source_person_test.py b/products/customer_analytics/backend/facade/custom_property_source_person_test.pyindex eb46b31c36a9..7cef8f6c9ff1 100644--- a/products/customer_analytics/backend/facade/custom_property_source_person_test.py+++ b/products/customer_analytics/backend/facade/custom_property_source_person_test.py@@ -8,6 +8,8 @@ from django.utils import timezonefrom parameterized import parameterized+from posthog.models import PropertyDefinition+from products.customer_analytics.backend.facade import apifrom products.customer_analytics.backend.models import CustomPropertySource, CustomPropertySyncRun, TargetTypefrom products.customer_analytics.backend.models.team_scoped_test_base import TeamScopedTestMixin@@ -206,6 +208,231 @@ class TestPersonCustomPropertySource(TeamScopedTestMixin, APIBaseTest):user_access_control=self._uac(allowed=False),)+ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_person_mapping_round_trips_on_the_same_source_and_starts_one_backfill(self, start_backfill):+ source = self._create(user_access_control=self._uac(allowed=True))+ start_backfill.reset_mock()+ CustomPropertySource.objects.filter(id=source.id).update(+ consecutive_failures=3, last_sync_error="previous sync failure"+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={+ "column_property_map": {"plan": "plan_tier", "seats": "seat_count"},+ "column_descriptions": {"seats": " Seat count "},+ },+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.id == source.id+ assert view.column_property_map == {"plan": "plan_tier", "seats": "seat_count"}+ assert view.column_descriptions == {"seats": "Seat count"}+ assert view.consecutive_failures == 3 and view.last_sync_error == "previous sync failure"+ start_backfill.assert_called_once()++ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_person_mapping_noop_does_not_start_a_backfill(self, start_backfill):+ source = self._create(user_access_control=self._uac(allowed=True))+ start_backfill.reset_mock()++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.id == source.id+ start_backfill.assert_not_called()++ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_person_descriptions_stamps_and_clears_provenance_without_a_backfill(self, start_backfill):+ source = self._create(+ column_descriptions={"plan": "Old description"}, user_access_control=self._uac(allowed=True)+ )+ start_backfill.reset_mock()+ definition = PropertyDefinition.objects.create(+ team=self.team,+ name="plan_tier",+ type=PropertyDefinition.Type.PERSON,+ warehouse_origin={"description": "Old description"},+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_descriptions": {"plan": " Plan tier "}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.column_descriptions == {"plan": "Plan tier"}+ definition.refresh_from_db()+ assert definition.warehouse_origin is not None+ assert definition.warehouse_origin["custom_property_source_id"] == str(source.id)+ assert definition.warehouse_origin["description"] == "Plan tier"++ cleared = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_descriptions": None},+ user_access_control=self._uac(allowed=True),+ )++ assert cleared is not None and cleared.column_descriptions == {}+ definition.refresh_from_db()+ assert definition.warehouse_origin is not None+ assert "description" not in definition.warehouse_origin+ start_backfill.assert_not_called()++ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_disabled_person_mapping_leaves_provenance_alone(self, start_backfill):+ # Provenance names the source that writes a property. A disabled source writes nothing, so+ # editing its mapping must not make it the owner of a definition it does not feed.+ source = self._create(is_enabled=False, user_access_control=self._uac(allowed=True))+ start_backfill.reset_mock()+ definition = PropertyDefinition.objects.create(+ team=self.team,+ name="plan_tier",+ type=PropertyDefinition.Type.PERSON,+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier"}, "column_descriptions": {"plan": "Plan tier"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.column_descriptions == {"plan": "Plan tier"}+ definition.refresh_from_db()+ assert definition.warehouse_origin is None+ start_backfill.assert_not_called()++ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_disabled_person_mapping_requires_editor_without_starting_a_backfill(self, start_backfill):+ source = self._create(is_enabled=False, user_access_control=self._uac(allowed=True))+ start_backfill.reset_mock()++ with self.assertRaises(api.ResourceForbiddenError):+ api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier", "seats": "seat_count"}},+ user_access_control=self._uac(allowed=False),+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier", "seats": "seat_count"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.column_property_map == {"plan": "plan_tier", "seats": "seat_count"}+ start_backfill.assert_not_called()++ def test_update_person_mapping_replacement_drops_descriptions_for_removed_columns(self):+ source = self._create(+ column_property_map={"plan": "plan_tier", "seats": "seat_count"},+ column_descriptions={"plan": "Plan tier", "seats": "Seat count"},+ user_access_control=self._uac(allowed=True),+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.column_descriptions == {"plan": "Plan tier"}++ @parameterized.expand(+ [+ ("empty_map", {"column_property_map": {}}, "non-empty object"),+ ("null_map", {"column_property_map": None}, "non-empty object"),+ ("blank_property", {"column_property_map": {"plan": ""}}, "non-empty property names"),+ ]+ )+ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ def test_update_person_mapping_rejects_invalid_input_before_persistence_or_backfill(+ self, _name, fields, expected_message, start_backfill+ ):+ source = self._create(user_access_control=self._uac(allowed=True))+ start_backfill.reset_mock()++ with self.assertRaisesMessage(api.CustomPropertySourceValidationError, expected_message):+ api.update_custom_property_source(team_id=self.team.id, source_id=source.id, fields=fields)++ row = CustomPropertySource.objects.unscoped().get(id=source.id)+ assert row.column_property_map == {"plan": "plan_tier"}+ start_backfill.assert_not_called()++ def test_update_person_source_drops_unmapped_descriptions_like_create(self):+ source = self._create(user_access_control=self._uac(allowed=True))++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_descriptions": {"plan": " Plan tier ", "unmapped": "ignored"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is not None and view.column_descriptions == {"plan": "Plan tier"}++ @parameterized.expand(["column_property_map", "column_descriptions"])+ def test_update_account_source_rejects_profile_mapping_fields(self, field):+ source = self._create(+ definition_id=self.account_def.id,+ external_data_schema_id=None,+ saved_query_id=self.saved_query.id,+ source_column="mrr",+ column_property_map=None,+ )++ value = {"mrr": "account_mrr"} if field == "column_property_map" else {"mrr": "Account MRR"}+ with self.assertRaisesMessage(api.CustomPropertySourceValidationError, "not external_data_schema"):+ api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={field: value},+ )++ def test_update_account_source_ignores_null_profile_mapping_fields(self):+ source = self._create(+ definition_id=self.account_def.id,+ external_data_schema_id=None,+ saved_query_id=self.saved_query.id,+ source_column="mrr",+ column_property_map=None,+ )++ view = api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": None, "column_descriptions": None},+ )++ assert view is not None+ assert view.column_property_map is None and view.column_descriptions is None++ def test_update_person_mapping_is_team_scoped(self):+ source = self._create(user_access_control=self._uac(allowed=True))+ other_team = self.organization.teams.create(name="other")++ view = api.update_custom_property_source(+ team_id=other_team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "other_plan"}},+ user_access_control=self._uac(allowed=True),+ )++ assert view is None+ row = CustomPropertySource.objects.unscoped().get(id=source.id)+ assert row.column_property_map == {"plan": "plan_tier"}+def test_delete_person_source_requires_warehouse_source_editor(self):# Deleting a person source permanently stops its billable warehouse-driven updates, so it needs# external_data_source editor access, not account-scope editor alone.@@ -390,6 +617,40 @@ class TestPersonCustomPropertySource(TeamScopedTestMixin, APIBaseTest):run.refresh_from_db()assert run.status == "failed"+ @patch("products.customer_analytics.backend.facade.api.person_properties_flag_enabled", return_value=True)+ def test_backfill_reports_false_when_only_a_sibling_source_starts(self, _flag):+ # Two enabled sources can bind the same schema. If this source's own run is already in+ # flight and only a sibling source gets a fresh placeholder, the caller must see the+ # coalesced result (False) for the source it actually asked about, not the sibling's.+ source = self._create(user_access_control=self._uac(allowed=True))+ sibling_def = create_custom_property_definition(+ team_id=self.team.id, name="Seats", target_type=TargetType.PERSON.value+ )+ sibling = self._create(+ definition_id=sibling_def.id,+ column_property_map={"seats": "seat_count"},+ user_access_control=self._uac(allowed=True),+ )+ CustomPropertySyncRun.objects.create(+ team_id=self.team.id,+ source_id=source.id,+ schema_id=self.schema.id,+ trigger="manual",+ status="running",+ started_at=timezone.now(),+ )++ with patch(+ "products.warehouse_sources.backend.facade.temporal.start_person_property_backfill", return_value=True+ ):+ result = api.trigger_person_property_backfill(+ team_id=self.team.id, source_id=source.id, user_access_control=self._uac(allowed=True)+ )++ assert result is False+ sibling_run = CustomPropertySyncRun.objects.unscoped().get(source_id=sibling.id)+ assert sibling_run.status == "running"+@patch("products.customer_analytics.backend.facade.api.person_properties_flag_enabled", return_value=True)def test_triggers_reject_disabled_source(self, _flag):# A disabled source can't be re-triggered: sync returns False (→ 400) and backfill None (→ 400).@@ -446,6 +707,24 @@ class TestPersonCustomPropertySource(TeamScopedTestMixin, APIBaseTest):with self.assertRaises(api.ResourceForbiddenError):self._create_view_source(user_access_control=self._uac(allowed=False))+ @patch("products.customer_analytics.backend.facade.api._start_person_backfill_if_enabled")+ @patch("products.customer_analytics.backend.facade.api._send_initial_account_property_sync")+ def test_view_backed_person_source_never_queues_account_sync(self, enqueue_account_sync, _start_backfill):+ with self.captureOnCommitCallbacks(execute=True):+ source = self._create_view_source(user_access_control=self._uac(allowed=True))++ enqueue_account_sync.assert_not_called()++ with self.captureOnCommitCallbacks(execute=True):+ api.update_custom_property_source(+ team_id=self.team.id,+ source_id=source.id,+ fields={"column_property_map": {"plan": "plan_tier", "seats": "seat_count"}},+ user_access_control=self._uac(allowed=True),+ )++ enqueue_account_sync.assert_not_called()+@patch("products.customer_analytics.backend.facade.api.person_properties_flag_enabled", return_value=True)def test_sync_now_materializes_the_view_and_opens_a_running_run(self, _flag):source = self._create_view_source(user_access_control=self._uac(allowed=True))diff --git a/products/customer_analytics/backend/presentation/views/serializers.py b/products/customer_analytics/backend/presentation/views/serializers.pyindex fd3bc49e8bff..2a5c5ccb2863 100644--- a/products/customer_analytics/backend/presentation/views/serializers.py+++ b/products/customer_analytics/backend/presentation/views/serializers.py@@ -1596,12 +1596,12 @@ class CustomPropertySyncTriggerResponseSerializer(serializers.Serializer):choices=[("triggered", "triggered"), ("started", "started"), ("already_running", "already_running")],help_text=("'triggered' (sync now started the warehouse sync), 'started' (a new backfill began), or "- "'already_running' (a backfill for this table was already in flight, so this was a no-op)."+ "'already_running' (a backfill was in flight and a latest-state follow-up was queued)."),)already_running = serializers.BooleanField(required=False,- help_text="Backfill only: true when a backfill for this table was already running and this call coalesced.",+ help_text="Backfill only: true when a run was already in flight and this call queued its follow-up.",)@@ -1763,7 +1763,7 @@ class CustomPropertySourceSerializer(DataclassSerializer):help_text=("Person and group sources only: {warehouse_column: description} giving each mapped column a ""human-facing description, seeded from the warehouse column's information_schema "- "description. Optional per column. Create-only."+ "description. Optional per column."),)key_column = serializers.CharField(@@ -2017,8 +2017,8 @@ class CustomPropertyDefinitionSerializer(DataclassSerializer):class CustomPropertySourceUpdateSerializer(serializers.Serializer):- """Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so- they are intentionally absent — only these reach the facade's update."""+ """Writable fields for updating a source. Binding and definition fields are create-only, so they+ are intentionally absent — only these reach the facade's update."""source_column = serializers.CharField(max_length=400, required=False, help_text="Column in the view whose value is written to the property."@@ -2026,6 +2026,21 @@ class CustomPropertySourceUpdateSerializer(serializers.Serializer):key_column = serializers.CharField(max_length=400, required=False, help_text="Column in the view whose value matches an account's external_id.")+ column_property_map = serializers.JSONField(+ required=False,+ allow_null=True,+ help_text=(+ "Person and group sources only: {warehouse_column: property_name} mapping the columns this "+ "source writes onto the person or group."+ ),+ )+ column_descriptions = serializers.JSONField(+ required=False,+ allow_null=True,+ help_text=(+ "Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column."+ ),+ )is_enabled = serializers.BooleanField(required=False, help_text="Whether the source syncs; re-enabling it resets the failure count.")diff --git a/products/customer_analytics/backend/presentation/views/views.py b/products/customer_analytics/backend/presentation/views/views.pyindex ab52598659f6..0bb9c8a9c671 100644--- a/products/customer_analytics/backend/presentation/views/views.py+++ b/products/customer_analytics/backend/presentation/views/views.py@@ -1462,6 +1462,8 @@ class CustomPropertySourceViewSet(fields=write.validated_data,user_access_control=_warehouse_scoped_uac(self),)+ except api.CustomPropertySourceValidationError as e:+ raise ValidationError(str(e))except api.ResourceForbiddenError:raise PermissionDenied()if source is None:@@ -1526,8 +1528,8 @@ class CustomPropertySourceViewSet(@action(methods=["POST"], detail=True)def backfill(self, request: Request, *args, **kwargs) -> Response:"""Person and group sources only: start a backfill that reads the whole warehouse table and- populates person or group properties for historical rows. Coalesces if one is already running- for the table."""+ populates person or group properties for historical rows. If one is already running for the+ table, queue a follow-up that observes the latest mapping."""self._guard_group_source(request, self.kwargs["pk"])try:started = api.trigger_person_property_backfill(diff --git a/products/customer_analytics/backend/test/test_views.py b/products/customer_analytics/backend/test/test_views.pyindex 4bcad46eb6aa..cc31293e65bc 100644--- a/products/customer_analytics/backend/test/test_views.py+++ b/products/customer_analytics/backend/test/test_views.py@@ -15,7 +15,7 @@ from rest_framework import statusfrom posthog.auth import MCP_USER_AGENT_MARKERfrom posthog.constants import AvailableFeature-from posthog.models import Tag, TaggedItem+from posthog.models import PropertyDefinition, Tag, TaggedItemfrom posthog.models.activity_logging.activity_log import ActivityLogfrom posthog.models.comment import Commentfrom posthog.models.integration import Integration@@ -2416,7 +2416,16 @@ class TestCustomPropertySourceViewSet(APIBaseTest):assert listed.status_code == status.HTTP_200_OKassert [s["id"] for s in listed.json()["results"]] == [source_id]- toggled = self.client.patch(f"{self.endpoint}{source_id}/", {"is_enabled": False}, format="json")+ detail_endpoint = f"{self.endpoint}{source_id}/"+ retrieved = self.client.get(detail_endpoint)+ assert retrieved.status_code == status.HTTP_200_OK+ assert retrieved.json()["column_property_map"] is None+ assert retrieved.json()["column_descriptions"] is None++ round_tripped = self.client.patch(detail_endpoint, retrieved.json(), format="json")+ assert round_tripped.status_code == status.HTTP_200_OK, round_tripped.content++ toggled = self.client.patch(detail_endpoint, {"is_enabled": False}, format="json")assert toggled.status_code == status.HTTP_200_OKassert toggled.json()["is_enabled"] is False@@ -2450,6 +2459,30 @@ class TestCustomPropertySourceViewSet(APIBaseTest):assert body["column_property_map"] == {"plan": "plan_tier"}assert body["saved_query"] is None+ def test_patch_person_source_mapping_round_trip_and_validation(self):+ source_id = self._create_person_source()++ patched = self.client.patch(+ f"{self.endpoint}{source_id}/",+ {+ "column_property_map": {"plan": "plan_tier", "seats": "seat_count"},+ "column_descriptions": {"seats": " Seat count "},+ },+ format="json",+ )++ assert patched.status_code == status.HTTP_200_OK, patched.content+ assert patched.json()["id"] == source_id+ assert patched.json()["column_property_map"] == {"plan": "plan_tier", "seats": "seat_count"}+ assert patched.json()["column_descriptions"] == {"seats": "Seat count"}++ invalid = self.client.patch(f"{self.endpoint}{source_id}/", {"column_property_map": {}}, format="json")+ assert invalid.status_code == status.HTTP_400_BAD_REQUEST, invalid.content++ cleared = self.client.patch(f"{self.endpoint}{source_id}/", {"column_descriptions": None}, format="json")+ assert cleared.status_code == status.HTTP_200_OK, cleared.content+ assert cleared.json()["column_descriptions"] == {}+@patch("products.customer_analytics.backend.presentation.views.views.report_user_action")def test_mapping_lifecycle_emits_usage_events(self, report_user_action):definition, schema = self._person_definition_and_schema()@@ -2526,7 +2559,7 @@ class TestCustomPropertySourceViewSet(APIBaseTest):@patch("posthoganalytics.feature_enabled", return_value=True)def test_person_source_actions_when_enabled(self, _flag, mock_trigger_sync, mock_start_backfill):# Wiring guard: the actions route through the facade to the temporal seam, return the typed- # response, and the backfill pre-creates a running run the runs feed then surfaces.+ # response, and an in-flight sync still sends the manual latest-revision follow-up.source_id = self._create_person_source()synced = self.client.post(f"{self.endpoint}{source_id}/sync/")@@ -2536,7 +2569,7 @@ class TestCustomPropertySourceViewSet(APIBaseTest):backfilled = self.client.post(f"{self.endpoint}{source_id}/backfill/")assert backfilled.status_code == status.HTTP_202_ACCEPTED, backfilled.content- assert backfilled.json() == {"status": "started", "already_running": False}+ assert backfilled.json() == {"status": "already_running", "already_running": True}mock_start_backfill.assert_called_once()runs = self.client.get(f"{self.endpoint}{source_id}/runs/")@@ -2565,7 +2598,7 @@ class TestCustomPropertySourceViewSet(APIBaseTest):{"definition": definition.json()["id"],"external_data_schema": str(schema.id),- "column_property_map": {"plan": "plan_tier"},+ "column_property_map": {"plan": "plan_tier_pending"},"key_column": "org_id",},format="json",@@ -2573,6 +2606,39 @@ class TestCustomPropertySourceViewSet(APIBaseTest):assert created.status_code == status.HTTP_201_CREATED, created.contentassert created.json()["external_data_schema"] == str(schema.id)+ # Settle the mapping to its tested value via an update. Provenance is stamped as soon as an+ # enabled source's effective mapping changes, without waiting for a value backfill.+ settled = self.client.patch(+ f"{self.endpoint}{created.json()['id']}/",+ {"column_property_map": {"plan": "plan_tier"}},+ format="json",+ )+ assert settled.status_code == status.HTTP_200_OK, settled.content+ old_definition = PropertyDefinition.objects.get(+ team_id=self.team.id, type=PropertyDefinition.Type.GROUP, group_type_index=0, name="plan_tier"+ )+ assert old_definition.warehouse_origin is not None+ assert old_definition.warehouse_origin["custom_property_source_id"] == created.json()["id"]++ patched = self.client.patch(+ f"{self.endpoint}{created.json()['id']}/",+ {"column_property_map": {"plan": "group_plan_tier"}},+ format="json",+ )+ assert patched.status_code == status.HTTP_200_OK, patched.content+ assert patched.json()["id"] == created.json()["id"]+ assert patched.json()["column_property_map"] == {"plan": "group_plan_tier"}++ # Regression: renaming a mapped column must not leave the old property definition claiming+ # this source indefinitely once it no longer produces that property.+ old_definition.refresh_from_db()+ assert old_definition.warehouse_origin is None+ new_definition = PropertyDefinition.objects.get(+ team_id=self.team.id, type=PropertyDefinition.Type.GROUP, group_type_index=0, name="group_plan_tier"+ )+ assert new_definition.warehouse_origin is not None+ assert new_definition.warehouse_origin["custom_property_source_id"] == created.json()["id"]+@parameterized.expand([("group_without_index", {"target_type": "group"}),diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.tsindex 84278e73971d..2a9288716c88 100644--- a/products/customer_analytics/frontend/generated/api.schemas.ts+++ b/products/customer_analytics/frontend/generated/api.schemas.ts@@ -2819,7 +2819,7 @@ export interface CustomPropertySourceApi {source_column?: string | null/** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */column_property_map?: unknown- /** Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. Create-only. */+ /** Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. */column_descriptions?: unknown/*** Column whose value identifies the target: an account's external_id for account sources, the person's distinct_id for person sources, or the group key for group sources.@@ -3058,8 +3058,8 @@ export interface PaginatedCustomPropertySourceListApi {}/**- * Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so- * they are intentionally absent — only these reach the facade's update.+ * Writable fields for updating a source. Binding and definition fields are create-only, so they+ * are intentionally absent — only these reach the facade's update.*/export interface CustomPropertySourceUpdateApi {/**@@ -3072,13 +3072,17 @@ export interface CustomPropertySourceUpdateApi {* @maxLength 400*/key_column?: string+ /** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */+ column_property_map?: unknown+ /** Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column. */+ column_descriptions?: unknown/** Whether the source syncs; re-enabling it resets the failure count. */is_enabled?: boolean}/**- * Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so- * they are intentionally absent — only these reach the facade's update.+ * Writable fields for updating a source. Binding and definition fields are create-only, so they+ * are intentionally absent — only these reach the facade's update.*/export interface PatchedCustomPropertySourceUpdateApi {/**@@ -3091,6 +3095,10 @@ export interface PatchedCustomPropertySourceUpdateApi {* @maxLength 400*/key_column?: string+ /** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */+ column_property_map?: unknown+ /** Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column. */+ column_descriptions?: unknown/** Whether the source syncs; re-enabling it resets the failure count. */is_enabled?: boolean}@@ -3113,13 +3121,13 @@ export const CustomPropertySyncTriggerResponseStatusEnumApi = {* Response of the person/group-property sync/backfill trigger actions.*/export interface CustomPropertySyncTriggerResponseApi {- /** 'triggered' (sync now started the warehouse sync), 'started' (a new backfill began), or 'already_running' (a backfill for this table was already in flight, so this was a no-op).+ /** 'triggered' (sync now started the warehouse sync), 'started' (a new backfill began), or 'already_running' (a backfill was in flight and a latest-state follow-up was queued).** * `triggered` - triggered* * `started` - started* * `already_running` - already_running */status: CustomPropertySyncTriggerResponseStatusEnumApi- /** Backfill only: true when a backfill for this table was already running and this call coalesced. */+ /** Backfill only: true when a run was already in flight and this call queued its follow-up. */already_running?: boolean}diff --git a/products/customer_analytics/frontend/generated/api.ts b/products/customer_analytics/frontend/generated/api.tsindex 16b6e95f2cb1..8eae47934c7e 100644--- a/products/customer_analytics/frontend/generated/api.ts+++ b/products/customer_analytics/frontend/generated/api.ts@@ -1441,8 +1441,8 @@ export const getCustomPropertySourcesBackfillUrl = (projectId: string, id: strin/*** Person and group sources only: start a backfill that reads the whole warehouse table and- * populates person or group properties for historical rows. Coalesces if one is already running- * for the table.+ * populates person or group properties for historical rows. If one is already running for the+ * table, queue a follow-up that observes the latest mapping.*/export const customPropertySourcesBackfill = async (projectId: string,diff --git a/products/customer_analytics/frontend/generated/api.zod.ts b/products/customer_analytics/frontend/generated/api.zod.tsindex 8f39604cdb9d..12707a9bb2b3 100644--- a/products/customer_analytics/frontend/generated/api.zod.ts+++ b/products/customer_analytics/frontend/generated/api.zod.ts@@ -824,7 +824,7 @@ export const CustomPropertySourcesCreateBody = /* @__PURE__ */ zod.unknown().optional().describe(- "Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. Create-only."+ "Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column."),key_column: zod.string()@@ -859,13 +859,25 @@ export const CustomPropertySourcesUpdateBody = /* @__PURE__ */ zod.max(customPropertySourcesUpdateBodyKeyColumnMax).optional().describe("Column in the view whose value matches an account's external_id."),+ column_property_map: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group.'+ ),+ column_descriptions: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column.'+ ),is_enabled: zod.boolean().optional().describe('Whether the source syncs; re-enabling it resets the failure count.'),}).describe(- "Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so\nthey are intentionally absent — only these reach the facade's update."+ "Writable fields for updating a source. Binding and definition fields are create-only, so they\nare intentionally absent — only these reach the facade's update.")export const customPropertySourcesPartialUpdateBodySourceColumnMax = 400@@ -884,13 +896,25 @@ export const CustomPropertySourcesPartialUpdateBody = /* @__PURE__ */ zod.max(customPropertySourcesPartialUpdateBodyKeyColumnMax).optional().describe("Column in the view whose value matches an account's external_id."),+ column_property_map: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group.'+ ),+ column_descriptions: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column.'+ ),is_enabled: zod.boolean().optional().describe('Whether the source syncs; re-enabling it resets the failure count.'),}).describe(- "Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so\nthey are intentionally absent — only these reach the facade's update."+ "Writable fields for updating a source. Binding and definition fields are create-only, so they\nare intentionally absent — only these reach the facade's update.")export const customerJourneysCreateBodyNameMax = 400diff --git a/products/warehouse_sources/backend/facade/person_property_provenance.py b/products/warehouse_sources/backend/facade/person_property_provenance.pynew file mode 100644index 000000000000..936b51c4e4da--- /dev/null+++ b/products/warehouse_sources/backend/facade/person_property_provenance.py@@ -0,0 +1,115 @@+"""Writes the warehouse mapping provenance carried on person and group property definitions.++Owned here so both writers share one implementation: the post-sync pipeline stamps it after a run,+and a mapping/description update from the API stamps it without waiting for the next value change.+"""++from collections.abc import Iterable++from django.db.models import Q++from posthog.models import PropertyDefinition++from products.warehouse_sources.backend.facade.hooks import WarehouseBinding++_GROUP_TARGET = "group"++# Keep this in lockstep with property-defs-rs: it admits property names up to half Django's+# CharField limit, measured as UTF-8 bytes, and sanitizes NULs immediately before persistence.+MAX_PROPERTY_NAME_BYTES = 200+++def stamp_person_property_provenance(+ *,+ team_id: int,+ project_id: int,+ binding: WarehouseBinding,+ source_id: str,+ definition_id: str,+ target: str,+ group_type_index: int | None,+ property_names: Iterable[str],+ property_descriptions: dict[str, str],+) -> None:+ """Record which warehouse source owns each mapped person/group property definition."""+ origin: dict[str, str] = {+ "source_id": definition_id,+ "custom_property_source_id": source_id,+ "binding_kind": binding.kind,+ "binding_id": binding.id,+ }+ # Kept for schema bindings: rows stamped before views were supported carry this key, so dropping+ # it would leave two stamps of the same schema describing it differently.+ if not binding.is_saved_query:+ origin["schema_id"] = binding.id++ canonical_descriptions: dict[str, str] = {}+ for name in property_names:+ if len(name.encode()) > MAX_PROPERTY_NAME_BYTES:+ continue+ canonical_name = name.replace("\x00", "\ufffd")+ canonical_descriptions.setdefault(canonical_name, property_descriptions.get(name, ""))++ if not canonical_descriptions:+ return++ names = list(canonical_descriptions)+ definition_type = PropertyDefinition.Type.PERSON+ definition_group_type_index = None+ if target == _GROUP_TARGET:+ if group_type_index is None:+ return+ definition_type = PropertyDefinition.Type.GROUP+ definition_group_type_index = group_type_index++ # Property definitions are unique and read by effective project. Include legacy rows whose+ # project_id is null so the conflict-safe insert and the final stamp address the same identity.+ query = PropertyDefinition.objects.filter(Q(project_id=project_id) | Q(project_id__isnull=True, team_id=project_id))+ if target == _GROUP_TARGET:+ # Group propdefs are keyed per group type, so the index predicate is mandatory.+ query = query.filter(type=PropertyDefinition.Type.GROUP, group_type_index=group_type_index)+ else:+ query = query.filter(type=PropertyDefinition.Type.PERSON)++ # A mapping update can rename or drop a column. Without this, the definition it used to feed+ # keeps claiming this source indefinitely, even though this source no longer produces it. Guarded+ # by an existence check so a steady-state reconciliation (nothing to clear) issues no UPDATE.+ stale_origins = query.filter(warehouse_origin__custom_property_source_id=source_id).exclude(name__in=names)+ if stale_origins.exists():+ stale_origins.update(warehouse_origin=None)++ current_origins = dict(query.filter(name__in=names).values_list("name", "warehouse_origin"))+ missing = [name for name in names if name not in current_origins]+ if missing:+ # Ingestion may create the same effective-project identity after the read above. Ignore that+ # conflict, then read back the winner before deciding which origins still need a write.+ PropertyDefinition.objects.bulk_create(+ [+ PropertyDefinition(+ team_id=team_id,+ project_id=project_id,+ name=name,+ type=definition_type,+ group_type_index=definition_group_type_index,+ warehouse_origin={+ **origin,+ **({"description": canonical_descriptions[name]} if canonical_descriptions[name] else {}),+ },+ )+ for name in missing+ ],+ ignore_conflicts=True,+ )+ current_origins.update(query.filter(name__in=missing).values_list("name", "warehouse_origin"))++ # Replacing the whole origin deliberately clears a previously configured description.+ plain = [name for name in names if not canonical_descriptions[name] and current_origins.get(name) != origin]+ if plain:+ query.filter(name__in=plain).update(warehouse_origin=origin)+ for name in names:+ description = canonical_descriptions[name]+ if not description:+ continue+ described_origin = {**origin, "description": description}+ if current_origins.get(name) != described_origin:+ query.filter(name=name).update(warehouse_origin=described_origin)diff --git a/products/warehouse_sources/backend/temporal/data_imports/external_product_hooks.py b/products/warehouse_sources/backend/temporal/data_imports/external_product_hooks.pyindex 2f5df8af4856..ecbb5d36c5d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/external_product_hooks.py+++ b/products/warehouse_sources/backend/temporal/data_imports/external_product_hooks.py@@ -305,6 +305,9 @@ class PersonPropertyBackfillActivityInputs:# "backfill" (auto on create/enable) or "manual" (a user asked to re-run). Recorded on the run.trigger: strsaved_query_id: uuid.UUID | None = None+ # Signal-with-start uses an empty workflow seed, then supplies the real activity input via its+ # start signal. The default preserves replay for executions started before that trigger existed.+ skip_initial_run: bool = False@propertydef binding(self) -> WarehouseBinding:diff --git a/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job.py b/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job.pyindex dc2fbbe58a08..47cd3263cff9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job.py+++ b/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job.py@@ -7,10 +7,11 @@ source on it, so mapping several properties from one table runs a single backfilan imported schema's or a materialized view's — the read is the same either way.Started from the customer_analytics facade (auto on mapping create/enable, or a manual "backfill"-button) with a per-``{team, binding}`` workflow id so concurrent triggers for the same table coalesce.-Runs on the DATA_WAREHOUSE_METADATA_TASK_QUEUE alongside the incremental sync so post-sync processing-never competes with the sync workers. The snapshot diff still skips unchanged values, so a re-run is-cheap and idempotent.+button) with a per-``{team, binding}`` workflow id. Concurrent triggers replace one pending request,+so an in-flight run is followed by a run that observes the latest committed mapping. Runs on the+DATA_WAREHOUSE_METADATA_TASK_QUEUE alongside the incremental sync so post-sync processing never+competes with the sync workers. The snapshot diff still skips unchanged values, so a re-run is cheap+and idempotent."""import json@@ -23,6 +24,7 @@ import structlogfrom prometheus_client import Counter, Histogramfrom temporalio import activity, workflowfrom temporalio.common import RetryPolicy+from temporalio.exceptions import ActivityErrorfrom posthog.exceptions_capture import capture_exceptionfrom posthog.temporal.common.base import PostHogWorkflow@@ -34,6 +36,7 @@ from products.warehouse_sources.backend.temporal.data_imports.external_product_hfrom products.warehouse_sources.backend.temporal.data_imports.pipelines.core.person_property_sync import (record_completed_runs,record_failed_runs,+ record_started_runs,run_person_property_backfill,)@@ -68,6 +71,13 @@ async def backfill_warehouse_person_properties_activity(inputs: PersonPropertyBastart = time.monotonic()started_at = datetime.now(UTC).isoformat()binding = inputs.binding+ await record_started_runs(+ team_id=inputs.team_id,+ binding=binding,+ job_id=None,+ trigger=inputs.trigger,+ started_at=started_at,+ )try:async with Heartbeater():result = await run_person_property_backfill(team_id=inputs.team_id, binding=binding, trigger=inputs.trigger)@@ -121,6 +131,25 @@ async def backfill_warehouse_person_properties_activity(inputs: PersonPropertyBa@workflow.defn(name="backfill-warehouse-person-properties")class BackfillWarehousePersonPropertiesWorkflow(PostHogWorkflow):+ @workflow.init+ def __init__(self, inputs: PersonPropertyBackfillActivityInputs) -> None:+ # Old executions were started directly with their activity input. Keeping that as the default+ # initial request makes their histories replay unchanged after signal-with-start is deployed.+ self._pending_inputs: PersonPropertyBackfillActivityInputs | None = None if inputs.skip_initial_run else inputs++ @workflow.signal+ async def request_backfill(self, inputs: PersonPropertyBackfillActivityInputs) -> None:+ # A binding backfill always resolves source mappings from the database when its activity runs.+ # Only the latest pending request is needed; replacing it coalesces bursts without losing the+ # revision that must run after the current activity.+ self._pending_inputs = dataclasses.replace(inputs, skip_initial_run=False)++ @property+ def _has_pending_request(self) -> bool:+ """Whether a request is queued. A signal handler can queue one during any await, so read+ this rather than the field: a narrowed field reads as empty for the rest of the run."""+ return self._pending_inputs is not None+@staticmethoddef parse_inputs(inputs: list[str]) -> PersonPropertyBackfillActivityInputs:loaded = json.loads(inputs[0])@@ -128,15 +157,36 @@ class BackfillWarehousePersonPropertiesWorkflow(PostHogWorkflow):@workflow.runasync def run(self, inputs: PersonPropertyBackfillActivityInputs) -> None:- await workflow.execute_activity(- backfill_warehouse_person_properties_activity,- inputs,- start_to_close_timeout=timedelta(hours=6),- heartbeat_timeout=timedelta(minutes=5),- # A one-off full-table read: don't silently re-scan the whole table on a transient error.- retry_policy=RetryPolicy(maximum_attempts=1),- )---PERSON_PROPERTY_BACKFILL_WORKFLOWS = [BackfillWarehousePersonPropertiesWorkflow]+ while True:+ await workflow.wait_condition(lambda: self._pending_inputs is not None)+ activity_inputs = self._pending_inputs+ self._pending_inputs = None+ assert activity_inputs is not None+ try:+ await workflow.execute_activity(+ backfill_warehouse_person_properties_activity,+ activity_inputs,+ start_to_close_timeout=timedelta(hours=6),+ heartbeat_timeout=timedelta(minutes=5),+ # A one-off full-table read: don't silently re-scan the whole table on a transient error.+ retry_policy=RetryPolicy(maximum_attempts=1),+ )+ except ActivityError:+ # The activity records its own failed runs before raising, so the failure already+ # reached the UI. A request that arrived while it ran was reported to its caller as+ # queued, so serve that before giving up — a mapping edit must not die with the run+ # it happened to overlap. With nothing pending, fail the workflow as before.+ await workflow.wait_condition(workflow.all_handlers_finished)+ if not self._has_pending_request:+ raise+ continue++ # Drain signal handlers and re-check before completing. A signal racing the completion+ # command makes Temporal replay this task; a signal after completion starts a fresh run.+ await workflow.wait_condition(workflow.all_handlers_finished)+ if not self._has_pending_request:+ return+++PERSON_PROPERTY_BACKFILL_WORKFLOWS: list[type[PostHogWorkflow]] = [BackfillWarehousePersonPropertiesWorkflow]PERSON_PROPERTY_BACKFILL_ACTIVITIES = [backfill_warehouse_person_properties_activity]diff --git a/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job_test.py b/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job_test.pyindex 066f09b64f77..261c3d305cab 100644--- a/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job_test.py+++ b/products/warehouse_sources/backend/temporal/data_imports/person_property_backfill_job_test.py@@ -1,8 +1,11 @@import uuid+import asyncio+import dataclassesimport pytestfrom unittest.mock import AsyncMock, patch+from temporalio.exceptions import ActivityErrorfrom temporalio.testing import ActivityEnvironmentfrom products.warehouse_sources.backend.temporal.data_imports import person_property_backfill_job as bj@@ -22,6 +25,19 @@ def _inputs(team_id: int) -> PersonPropertyBackfillActivityInputs:)+def _activity_error() -> ActivityError:+ """What ``execute_activity`` raises once the activity exhausts its single attempt."""+ return ActivityError(+ "backfill failed",+ scheduled_event_id=1,+ started_event_id=2,+ identity="test",+ activity_type="backfill-warehouse-person-properties",+ activity_id="1",+ retry_state=None,+ )++@pytest.mark.django_db(transaction=True)class TestBackfillWarehousePersonPropertiesActivity:async def test_records_one_stage_per_nonzero_funnel_count(self) -> None:@@ -31,6 +47,7 @@ class TestBackfillWarehousePersonPropertiesActivity:result = SyncResult(sources=1, rows_read=5, changed=3, existing=0, produced=3, skipped_missing_person=1)with (patch.object(bj, "run_person_property_backfill", AsyncMock(return_value=result)),+ patch.object(bj, "record_started_runs", AsyncMock()) as mock_started,patch.object(bj, "record_completed_runs", AsyncMock()) as mock_record,):returned = await ActivityEnvironment().run(@@ -46,6 +63,7 @@ class TestBackfillWarehousePersonPropertiesActivity:"skipped_missing_person": 1,"per_source": [],}+ mock_started.assert_awaited_once()mock_record.assert_awaited_once()def stage_value(stage: str) -> float:@@ -78,3 +96,94 @@ class TestBackfillWarehousePersonPropertiesActivity:assert stage_value("existing") == 10assert stage_value("changed") == 0assert stage_value("produced") == 0+++async def test_in_flight_backfill_runs_one_follow_up_with_the_latest_request() -> None:+ first = _inputs(900003)+ middle = dataclasses.replace(first, schema_name="users-v2")+ latest = dataclasses.replace(first, schema_name="users-v3")+ seed = dataclasses.replace(first, skip_initial_run=True)+ runner = bj.BackfillWarehousePersonPropertiesWorkflow(seed)+ await runner.request_backfill(first)++ first_started = asyncio.Event()+ release_first = asyncio.Event()+ observed: list[PersonPropertyBackfillActivityInputs] = []++ async def execute_activity(_activity, inputs, **_kwargs):+ observed.append(inputs)+ if len(observed) == 1:+ first_started.set()+ await release_first.wait()++ with (+ patch.object(bj.workflow, "execute_activity", AsyncMock(side_effect=execute_activity)),+ patch.object(bj.workflow, "wait_condition", AsyncMock()),+ ):+ running = asyncio.create_task(runner.run(seed))+ await first_started.wait()+ await runner.request_backfill(middle)+ await runner.request_backfill(latest)+ release_first.set()+ await running++ assert observed == [first, latest]+++async def test_a_failed_run_still_serves_a_request_that_arrived_while_it_ran() -> None:+ # The API reports a request that lands mid-run as queued, so losing it with the run it happened+ # to overlap would strand a mapping edit with nothing telling the user.+ first = _inputs(900004)+ latest = dataclasses.replace(first, schema_name="users-v2")+ seed = dataclasses.replace(first, skip_initial_run=True)+ runner = bj.BackfillWarehousePersonPropertiesWorkflow(seed)+ await runner.request_backfill(first)++ first_started = asyncio.Event()+ release_first = asyncio.Event()+ observed: list[PersonPropertyBackfillActivityInputs] = []++ async def execute_activity(_activity, inputs, **_kwargs):+ observed.append(inputs)+ if len(observed) == 1:+ first_started.set()+ await release_first.wait()+ raise _activity_error()++ with (+ patch.object(bj.workflow, "execute_activity", AsyncMock(side_effect=execute_activity)),+ patch.object(bj.workflow, "wait_condition", AsyncMock()),+ ):+ running = asyncio.create_task(runner.run(seed))+ await first_started.wait()+ await runner.request_backfill(latest)+ release_first.set()+ await running++ assert observed == [first, latest]+++async def test_a_failed_run_with_nothing_queued_fails_the_workflow() -> None:+ # Swallowing the failure outright would report a backfill that never ran as a clean completion.+ only = _inputs(900005)+ seed = dataclasses.replace(only, skip_initial_run=True)+ runner = bj.BackfillWarehousePersonPropertiesWorkflow(seed)+ await runner.request_backfill(only)++ observed: list[PersonPropertyBackfillActivityInputs] = []++ async def execute_activity(_activity, inputs, **_kwargs):+ observed.append(inputs)+ raise _activity_error()++ with (+ patch.object(bj.workflow, "execute_activity", AsyncMock(side_effect=execute_activity)),+ patch.object(bj.workflow, "wait_condition", AsyncMock()),+ pytest.raises(ActivityError),+ ):+ await runner.run(seed)++ assert observed == [only]diff --git a/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers.py b/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers.pyindex b1b3ee96f07d..9a545bebff00 100644--- a/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers.py+++ b/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers.py@@ -9,6 +9,7 @@ Every entry point opens a Temporal client, so this module must stay off the ``djit's reached only from the facade on a request, never from an AppConfig or model."""+import dataclassesfrom uuid import UUIDfrom django.conf import settings@@ -16,8 +17,7 @@ from django.conf import settingsimport structlogfrom asgiref.sync import async_to_syncfrom temporalio.client import Client-from temporalio.common import WorkflowIDReusePolicy-from temporalio.exceptions import WorkflowAlreadyStartedError+from temporalio.common import WorkflowIDConflictPolicy, WorkflowIDReusePolicyfrom posthog.exceptions_capture import capture_exceptionfrom posthog.temporal.common.client import async_connect, sync_connect@@ -33,6 +33,7 @@ from products.warehouse_sources.backend.temporal.data_imports.external_product_hlogger = structlog.get_logger(__name__)BACKFILL_WORKFLOW_NAME = "backfill-warehouse-person-properties"+BACKFILL_SIGNAL_NAME = "request_backfill"# The canonical warehouse schema reload/resync endpoints reject a manual sync with this message when# the team's syncing is paused (monthly limit reached); reused so person-property "sync now" matches.@@ -89,19 +90,17 @@ def trigger_schema_sync(*, team_id: int, schema_id: str) -> None:log.info("Triggered warehouse schema sync for person-property sync-now")-def start_person_property_backfill(*, team_id: int, binding: WarehouseBinding, trigger: str) -> bool:- """Start the per-table backfill workflow. One workflow per ``{team, binding}`` (id-keyed), so- concurrent triggers for the same table coalesce: returns False (does not raise) when one is- already running. Raises ``WarehouseBindingMissingError`` when the warehouse object no longer- exists, kept distinct from the coalesced False so the caller can fail the run rows it created- rather than reporting a coalesced run for a table that is gone."""+def start_person_property_backfill(*, team_id: int, binding: WarehouseBinding, trigger: str) -> None:+ """Request a per-table backfill. One workflow per ``{team, binding}`` serializes runs; a request+ received while its activity is in flight replaces the pending request and guarantees a latest-state+ follow-up. Raises ``WarehouseBindingMissingError`` when the warehouse object no longer exists."""log = logger.bind(team_id=team_id, binding_kind=binding.kind, binding_id=binding.id, trigger=trigger)inputs = _backfill_inputs(team_id, binding, trigger)if inputs is None:log.warning("person-property backfill not started: warehouse object no longer exists")raise WarehouseBindingMissingErrorworkflow_id = f"{BACKFILL_WORKFLOW_NAME}-{team_id}-{binding.id}"- return _start_backfill_workflow(inputs, workflow_id)+ _start_backfill_workflow(inputs, workflow_id)def _backfill_inputs(@@ -177,25 +176,23 @@ def trigger_saved_query_materialization(*, team_id: int, saved_query_id: str) ->@async_to_sync-async def _start_backfill_workflow(inputs: PersonPropertyBackfillActivityInputs, workflow_id: str) -> bool:+async def _start_backfill_workflow(inputs: PersonPropertyBackfillActivityInputs, workflow_id: str) -> None:log = logger.bind(workflow_id=workflow_id, **inputs.properties_to_log)try:client: Client = await async_connect()- # ALLOW_DUPLICATE so a manual re-backfill is allowed after a prior run closes; a run currently- # in flight for the same id raises WorkflowAlreadyStartedError, which we swallow to coalesce.+ # Atomic signal-with-start: route to the binding's current execution, or start a fresh one after+ # the prior execution closes. The empty seed avoids running the same request twice on a new run.await client.start_workflow(BACKFILL_WORKFLOW_NAME,- inputs,+ dataclasses.replace(inputs, skip_initial_run=True),id=workflow_id,task_queue=settings.DATA_WAREHOUSE_METADATA_TASK_QUEUE,+ id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,+ start_signal=BACKFILL_SIGNAL_NAME,+ start_signal_args=[inputs],)- log.info("Started person-property backfill workflow")- return True- except WorkflowAlreadyStartedError:- # Expected: a backfill for this table is already in flight, so this trigger coalesces into it.- log.info("person-property backfill already running for binding, coalescing")- return False+ log.info("Requested person-property backfill workflow")except Exception as e:# A real failure to reach Temporal — capture it; the caller (facade) treats a raise as# "start failed" and the placeholder running row is reconciled to failed by the next run.diff --git a/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers_test.py b/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers_test.pyindex e2968f54c0bc..f008e4717c1f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers_test.py+++ b/products/warehouse_sources/backend/temporal/data_imports/person_property_triggers_test.py@@ -1,5 +1,9 @@+import dataclasses+import pytest-from unittest.mock import patch+from unittest.mock import AsyncMock, MagicMock, patch++from temporalio.common import WorkflowIDConflictPolicy, WorkflowIDReusePolicyfrom products.warehouse_sources.backend.temporal.data_imports import person_property_triggersfrom products.warehouse_sources.backend.temporal.data_imports.person_property_triggers import (@@ -27,3 +31,30 @@ def test_trigger_schema_sync_blocked_when_paused(_paused, mock_connect):def test_trigger_schema_sync_triggers_when_not_paused(_paused, _connect, mock_trigger_schedule):trigger_schema_sync(team_id=1, schema_id="abc")mock_trigger_schedule.assert_called_once()+++def test_backfill_request_uses_signal_with_start_for_the_binding_workflow():+ inputs = person_property_triggers.PersonPropertyBackfillActivityInputs(+ team_id=1,+ schema_id=None,+ saved_query_id=None,+ source_type="Stripe",+ schema_name="users",+ trigger="backfill",+ )+ client = MagicMock()+ client.start_workflow = AsyncMock()++ with patch.object(person_property_triggers, "async_connect", AsyncMock(return_value=client)):+ person_property_triggers._start_backfill_workflow(inputs, "backfill-1-schema")++ client.start_workflow.assert_awaited_once_with(+ person_property_triggers.BACKFILL_WORKFLOW_NAME,+ dataclasses.replace(inputs, skip_initial_run=True),+ id="backfill-1-schema",+ task_queue=person_property_triggers.settings.DATA_WAREHOUSE_METADATA_TASK_QUEUE,+ id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,+ id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,+ start_signal=person_property_triggers.BACKFILL_SIGNAL_NAME,+ start_signal_args=[inputs],+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/person_property_sync.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/person_property_sync.pyindex 468fafc475a0..bf95cdaa2433 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/person_property_sync.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/person_property_sync.py@@ -31,7 +31,6 @@ from decimal import Decimalfrom typing import Anyfrom django.conf import settings-from django.db.models import Qimport structlogimport pyarrow.parquet as pq@@ -40,13 +39,14 @@ from posthog.dataclasses import frozenfrom posthog.exceptions_capture import capture_exceptionfrom posthog.kafka_client.routing import producer_scopefrom posthog.kafka_client.topics import KAFKA_WAREHOUSE_PERSON_PROPERTY_UPDATES-from posthog.models import PropertyDefinition, Team+from posthog.models import Teamfrom posthog.models.group.util import get_groups_by_identifiersfrom posthog.models.group_type_mapping import get_group_types_for_projectfrom posthog.models.person.util import get_persons_mapped_by_distinct_idfrom posthog.sync import database_sync_to_asyncfrom products.data_warehouse.backend.facade.api import aget_s3_client+from products.warehouse_sources.backend.facade.person_property_provenance import stamp_person_property_provenancefrom products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchemafrom products.warehouse_sources.backend.temporal.data_imports.external_product_hooks import (PersonPropertySyncRunRecord,@@ -70,10 +70,6 @@ EVENT_SOURCE = "customer_analytics_person_property_sync"# customer_analytics config models, matching the isolation the hooks already preserve)._GROUP_TARGET = "group"-# Keep this in lockstep with property-defs-rs: it admits property names up to half Django's-# CharField limit, measured as UTF-8 bytes, and sanitizes NULs immediately before persistence.-_MAX_PROPERTY_NAME_BYTES = 200-def _log_fields(binding: WarehouseBinding) -> dict[str, str]:"""Structlog fields naming the warehouse object a run read from."""@@ -426,82 +422,17 @@ def _reconcile_property_definitions(source: PersonPropertySyncSource,property_names: list[str],) -> None:- origin: dict[str, str] = {- "source_id": str(source.definition_id),- "custom_property_source_id": str(source.source_id),- "binding_kind": binding.kind,- "binding_id": binding.id,- }- # Kept for schema bindings: rows stamped before views were supported carry this key, so dropping- # it would leave two stamps of the same schema describing it differently.- if not binding.is_saved_query:- origin["schema_id"] = binding.id-- descriptions = source.property_descriptions or {}- canonical_descriptions: dict[str, str] = {}- for name in property_names:- if len(name.encode()) > _MAX_PROPERTY_NAME_BYTES:- continue- canonical_name = name.replace("\x00", "\ufffd")- canonical_descriptions.setdefault(canonical_name, descriptions.get(name, ""))-- if not canonical_descriptions:- return-- property_names = list(canonical_descriptions)- definition_type = PropertyDefinition.Type.PERSON- group_type_index = None- if source.target == _GROUP_TARGET:- if source.group_type_index is None:- return- definition_type = PropertyDefinition.Type.GROUP- group_type_index = source.group_type_index-- # Property definitions are unique and read by effective project. Include legacy rows whose- # project_id is null so the conflict-safe insert and the final stamp address the same identity.- query = PropertyDefinition.objects.filter(Q(project_id=project_id) | Q(project_id__isnull=True, team_id=project_id))- if source.target == _GROUP_TARGET:- # Group propdefs are keyed per group type, so the index predicate is mandatory.- query = query.filter(type=PropertyDefinition.Type.GROUP, group_type_index=source.group_type_index)- else:- query = query.filter(type=PropertyDefinition.Type.PERSON)-- current_origins = dict(query.filter(name__in=property_names).values_list("name", "warehouse_origin"))- missing = [name for name in property_names if name not in current_origins]- if missing:- # Ingestion may create the same effective-project identity after the read above. Ignore that- # conflict, then read back the winner before deciding which origins still need a write.- PropertyDefinition.objects.bulk_create(- [- PropertyDefinition(- team_id=team_id,- project_id=project_id,- name=name,- type=definition_type,- group_type_index=group_type_index,- warehouse_origin={- **origin,- **({"description": canonical_descriptions[name]} if canonical_descriptions[name] else {}),- },- )- for name in missing- ],- ignore_conflicts=True,- )- current_origins.update(query.filter(name__in=missing).values_list("name", "warehouse_origin"))-- plain = [- name for name in property_names if not canonical_descriptions[name] and current_origins.get(name) != origin- ]- if plain:- query.filter(name__in=plain).update(warehouse_origin=origin)- for name in property_names:- description = canonical_descriptions[name]- if not description:- continue- described_origin = {**origin, "description": description}- if current_origins.get(name) != described_origin:- query.filter(name=name).update(warehouse_origin=described_origin)+ stamp_person_property_provenance(+ team_id=team_id,+ project_id=project_id,+ binding=binding,+ source_id=str(source.source_id),+ definition_id=str(source.definition_id),+ target=source.target,+ group_type_index=source.group_type_index,+ property_names=property_names,+ property_descriptions=source.property_descriptions or {},+ )# --- orchestration -----------------------------------------------------------------------diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 86427237265c..3665e5cdc7b0 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -24248,7 +24248,7 @@ export namespace Schemas {source_column?: string | null;/** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */column_property_map?: unknown;- /** Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. Create-only. */+ /** Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. */column_descriptions?: unknown;/*** Column whose value identifies the target: an account's external_id for account sources, the person's distinct_id for person sources, or the group key for group sources.@@ -24383,8 +24383,8 @@ export namespace Schemas {}/**- * Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so- * they are intentionally absent — only these reach the facade's update.+ * Writable fields for updating a source. Binding and definition fields are create-only, so they+ * are intentionally absent — only these reach the facade's update.*/export interface CustomPropertySourceUpdate {/**@@ -24397,6 +24397,10 @@ export namespace Schemas {* @maxLength 400*/key_column?: string;+ /** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */+ column_property_map?: unknown;+ /** Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column. */+ column_descriptions?: unknown;/** Whether the source syncs; re-enabling it resets the failure count. */is_enabled?: boolean;}@@ -24419,13 +24423,13 @@ export namespace Schemas {* Response of the person/group-property sync/backfill trigger actions.*/export interface CustomPropertySyncTriggerResponse {- /** 'triggered' (sync now started the warehouse sync), 'started' (a new backfill began), or 'already_running' (a backfill for this table was already in flight, so this was a no-op).+ /** 'triggered' (sync now started the warehouse sync), 'started' (a new backfill began), or 'already_running' (a backfill was in flight and a latest-state follow-up was queued).** * `triggered` - triggered* * `started` - started* * `already_running` - already_running */status: CustomPropertySyncTriggerResponseStatusEnum;- /** Backfill only: true when a backfill for this table was already running and this call coalesced. */+ /** Backfill only: true when a run was already in flight and this call queued its follow-up. */already_running?: boolean;}@@ -72588,8 +72592,8 @@ export namespace Schemas {}/**- * Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so- * they are intentionally absent — only these reach the facade's update.+ * Writable fields for updating a source. Binding and definition fields are create-only, so they+ * are intentionally absent — only these reach the facade's update.*/export interface PatchedCustomPropertySourceUpdate {/**@@ -72602,6 +72606,10 @@ export namespace Schemas {* @maxLength 400*/key_column?: string;+ /** Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group. */+ column_property_map?: unknown;+ /** Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column. */+ column_descriptions?: unknown;/** Whether the source syncs; re-enabling it resets the failure count. */is_enabled?: boolean;}diff --git a/services/mcp/src/generated/customer_analytics/api.ts b/services/mcp/src/generated/customer_analytics/api.tsindex 259ed3449998..3006cae96ca0 100644--- a/services/mcp/src/generated/customer_analytics/api.ts+++ b/services/mcp/src/generated/customer_analytics/api.ts@@ -808,7 +808,7 @@ export const CustomPropertySourcesCreateBody = () => zod.unknown().optional().describe(- "Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column. Create-only."+ "Person and group sources only: {warehouse_column: description} giving each mapped column a human-facing description, seeded from the warehouse column's information_schema description. Optional per column."),key_column: zod.string()@@ -861,13 +861,25 @@ export const CustomPropertySourcesPartialUpdateBody = () => zod.max(customPropertySourcesPartialUpdateBodyKeyColumnMax).optional().describe("Column in the view whose value matches an account's external_id."),+ column_property_map: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: property_name} mapping the columns this source writes onto the person or group.'+ ),+ column_descriptions: zod+ .unknown()+ .optional()+ .describe(+ 'Person and group sources only: {warehouse_column: description} for mapped columns. Optional per column.'+ ),is_enabled: zod.boolean().optional().describe('Whether the source syncs; re-enabling it resets the failure count.'),}).describe(- "Writable fields for updating a source. ``definition`` and ``saved_query`` are create-only, so\nthey are intentionally absent — only these reach the facade's update."+ "Writable fields for updating a source. Binding and definition fields are create-only, so they\nare intentionally absent — only these reach the facade's update.")export const CustomPropertySourcesDestroyParams = () => zod.object({@@ -881,8 +893,8 @@ export const CustomPropertySourcesDestroyParams = () => zod.object({/*** Person and group sources only: start a backfill that reads the whole warehouse table and- * populates person or group properties for historical rows. Coalesces if one is already running- * for the table.+ * populates person or group properties for historical rows. If one is already running for the+ * table, queue a follow-up that observes the latest mapping.*/export const CustomPropertySourcesBackfillParams = () => zod.object({id: zod.string(),diff --git a/services/mcp/src/tools/generated/customer_analytics.ts b/services/mcp/src/tools/generated/customer_analytics.tsindex 7b905d2913cd..5220a2bb9694 100644--- a/services/mcp/src/tools/generated/customer_analytics.ts+++ b/services/mcp/src/tools/generated/customer_analytics.ts@@ -1052,6 +1052,12 @@ const customPropertySourcesPartialUpdate = (): ToolBase<if (params.key_column !== undefined) {body['key_column'] = params.key_column}+ if (params.column_property_map !== undefined) {+ body['column_property_map'] = params.column_property_map+ }+ if (params.column_descriptions !== undefined) {+ body['column_descriptions'] = params.column_descriptions+ }if (params.is_enabled !== undefined) {body['is_enabled'] = params.is_enabled}