: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-catalog): let editors reassign a metric's owner (#123515)
Thiago Salvatoreaad1789f6f70
diff --git a/products/data_catalog/backend/logic/metrics.py b/products/data_catalog/backend/logic/metrics.pyindex 1285b7374a44..e0b43eef3bb0 100644--- a/products/data_catalog/backend/logic/metrics.py+++ b/products/data_catalog/backend/logic/metrics.py@@ -422,7 +422,10 @@ def update_metric(team=team,user=user,request=request,- extra={"renamed_from": renamed_from} if renamed_from else None,+ extra={+ "updated_fields": sorted(fields),+ **({"renamed_from": renamed_from} if renamed_from else {}),+ },)return metricdiff --git a/products/data_catalog/backend/presentation/serializers.py b/products/data_catalog/backend/presentation/serializers.pyindex 6a1c0c4660d0..267b67793d48 100644--- a/products/data_catalog/backend/presentation/serializers.py+++ b/products/data_catalog/backend/presentation/serializers.py@@ -10,6 +10,7 @@ from drf_spectacular.utils import extend_schema_field, extend_schema_serializerfrom rest_framework import serializersfrom posthog.api.shared import UserBasicSerializer+from posthog.models import Userfrom posthog.schema_enums import IntervalTypefrom ..facade import api@@ -28,6 +29,23 @@ class _FreeJSONField(serializers.JSONField):"""A free-form JSON value (query results / query status shapes)."""+class MetricOwnerField(serializers.EmailField):+ def get_attribute(self, instance: Metric) -> str | None:+ return instance.owner.email if instance.owner else None++ def run_validation(self, data: object = serializers.empty) -> User | None:+ email = super().run_validation(data)+ if email is None:+ return None+ team = self.context["get_team"]()+ owner = User.objects.filter(+ email__iexact=email, organization_membership__organization_id=team.organization_id+ ).first()+ if owner is None:+ raise serializers.ValidationError("No member of this organization has this email.")+ return owner++@extend_schema_serializer(component_name="DataCatalogMetricRun")class MetricRunResponseSerializer(serializers.Serializer):"""Normalized envelope returned by the metric-run endpoint."""@@ -125,8 +143,12 @@ class MetricSerializer(serializers.ModelSerializer):required=False,help_text="Whether a human ('user') or an agent ('ai_generated') authored this metric.",)- owner = serializers.SerializerMethodField(- help_text="Email of the human accountable for this metric, or null.",+ owner = MetricOwnerField(+ required=False,+ allow_null=True,+ help_text="Email of the human accountable for this metric, or null. Set it to the email of a member of "+ "this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's "+ "approval.",)created_by = UserBasicSerializer(read_only=True, help_text="User who first created this metric.")approved_by = UserBasicSerializer(@@ -205,10 +227,6 @@ class MetricSerializer(serializers.ModelSerializer):},}- @extend_schema_field(serializers.CharField(allow_null=True))- def get_owner(self, obj: Metric) -> str | None:- return obj.owner.email if obj.owner else None-@extend_schema_field(OpenApiTypes.BOOL)def get_is_drifted(self, obj: Metric) -> bool:# The list view precomputes drift for the whole page into ``drift_map`` (one bulk query);diff --git a/products/data_catalog/backend/presentation/views.py b/products/data_catalog/backend/presentation/views.pyindex 2137c9d8396d..4a750b976551 100644--- a/products/data_catalog/backend/presentation/views.py+++ b/products/data_catalog/backend/presentation/views.py@@ -201,6 +201,7 @@ class MetricViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):for key in ("display_name","unit",+ "owner","definition","source_insight_short_id","created_source",diff --git a/products/data_catalog/backend/tests/test_analytics.py b/products/data_catalog/backend/tests/test_analytics.pyindex 4063056cb6c1..aa5baa209dfe 100644--- a/products/data_catalog/backend/tests/test_analytics.py+++ b/products/data_catalog/backend/tests/test_analytics.py@@ -10,7 +10,7 @@ from posthog.hogql.errors import ExposedHogQLErrorfrom products.data_catalog.backend.logic.certifications import propose_certificationfrom products.data_catalog.backend.logic.exceptions import MetricDriftedfrom products.data_catalog.backend.logic.execution import run_metric-from products.data_catalog.backend.logic.metrics import approve_metric, upsert_metric+from products.data_catalog.backend.logic.metrics import approve_metric, update_metric, upsert_metricfrom products.data_catalog.backend.logic.relationships import propose_relationshipfrom products.product_analytics.backend.facade.models import Insightfrom products.warehouse_sources.backend.facade.models import DataWarehouseTable@@ -69,6 +69,17 @@ class TestDataCatalogAnalytics(BaseTest):[blocked] = _catalog_calls(capture)assert blocked.kwargs["properties"]["reason"] == "drifted"+ @patch(_CAPTURE)+ def test_update_event_lists_the_updated_fields(self, capture: MagicMock) -> None:+ metric = upsert_metric(team=self.team, user=self.user, name="mrr", description="d")+ capture.reset_mock()++ update_metric(metric, team=self.team, user=self.user, owner=None, unit="usd")++ [updated] = _catalog_calls(capture)+ assert updated.kwargs["event"] == "data catalog metric updated"+ assert updated.kwargs["properties"]["updated_fields"] == ["owner", "unit"]+@parameterized.expand([("definition_error", {"side_effect": ExposedHogQLError("no such table")}),diff --git a/products/data_catalog/backend/tests/test_api.py b/products/data_catalog/backend/tests/test_api.pyindex 6fa4c9be5af6..c2db907221de 100644--- a/products/data_catalog/backend/tests/test_api.py+++ b/products/data_catalog/backend/tests/test_api.py@@ -10,8 +10,9 @@ from parameterized import parameterizedfrom rest_framework import statusfrom posthog.constants import AvailableFeature+from posthog.models import Userfrom posthog.models.activity_logging.activity_log import ActivityLog-from posthog.models.organization import OrganizationMembership+from posthog.models.organization import Organization, OrganizationMembershipfrom posthog.models.personal_api_key import PersonalAPIKeyfrom posthog.models.team import Teamfrom posthog.models.utils import generate_random_token_personal, hash_key_value@@ -132,6 +133,49 @@ class TestMetricAPI(APIBaseTest):assert self.client.get(f"{self.url}mrr/").status_code == status.HTTP_404_NOT_FOUNDassert self.client.get(f"{self.url}arr/").status_code == status.HTTP_200_OK+ @parameterized.expand(+ [+ ("reassign_to_member", "[email protected]", status.HTTP_200_OK, "[email protected]"),+ ("clear", None, status.HTTP_200_OK, None),+ ("reject_outsider", "[email protected]", status.HTTP_400_BAD_REQUEST, "[email protected]"),+ ]+ )+ def test_patch_owner_keeps_approval(+ self, _name: str, owner: str | None, expected_status: int, expected_owner: str | None+ ) -> None:+ User.objects.create_and_join(self.organization, "[email protected]", None)+ User.objects.create_and_join(Organization.objects.create(name="Other"), "[email protected]", None)+ self.client.post(self.url, {"name": "mrr", "description": "v1"}, format="json")+ self.client.post(f"{self.url}mrr/approve/")++ response = self.client.patch(f"{self.url}mrr/", {"owner": owner}, format="json")++ assert response.status_code == expected_status, response.json()+ body = self.client.get(f"{self.url}mrr/").json()+ assert body["owner"] == expected_owner+ assert body["status"] == MetricStatus.APPROVED++ @parameterized.expand(+ [+ ("member", {"owner": "[email protected]"}, status.HTTP_201_CREATED, "[email protected]"),+ ("explicit_null", {"owner": None}, status.HTTP_201_CREATED, None),+ ("omitted_defaults_to_caller", {}, status.HTTP_201_CREATED, "[email protected]"),+ ("reject_outsider", {"owner": "[email protected]"}, status.HTTP_400_BAD_REQUEST, None),+ ]+ )+ def test_create_assigns_owner(+ self, _name: str, owner_payload: dict, expected_status: int, expected_owner: str | None+ ) -> None:+ User.objects.create_and_join(self.organization, "[email protected]", None)+ User.objects.create_and_join(Organization.objects.create(name="Other"), "[email protected]", None)++ response = self.client.post(self.url, {"name": "mrr", "description": "v1", **owner_payload}, format="json")++ assert response.status_code == expected_status, response.json()+ created = Metric.objects.for_team(self.team.id).filter(name="mrr").select_related("owner").first()+ assert (created.owner.email if created and created.owner else None) == expected_owner+ assert (created is not None) == (expected_status == status.HTTP_201_CREATED)+def test_create_after_delete_starts_fresh(self) -> None:created = self.client.post(self.url, {"name": "mrr", "description": "v1", "definition": _HOGQL}, format="json"diff --git a/products/data_catalog/frontend/DataCatalogMetricScene.tsx b/products/data_catalog/frontend/DataCatalogMetricScene.tsxindex 9946bd61ec3d..488d70d8fff0 100644--- a/products/data_catalog/frontend/DataCatalogMetricScene.tsx+++ b/products/data_catalog/frontend/DataCatalogMetricScene.tsx@@ -44,6 +44,7 @@ import { InsightShortId, SidePanelTab } from '~/types'import { humanizeDefinitionKind, METRIC_DESCRIPTION_MAX_LENGTH, validateMetricName } from './common'import { MetricDefinition } from './components/MetricDefinition'+import { MetricOwnerSelect } from './components/MetricOwnerSelect'import { buildMetricRunPrompt } from './components/RunMetricWithAIButton'import { buildDataCatalogMetricAgentContext, DATA_CATALOG_METRIC_AGENT_HEADLINES } from './dataCatalogAgentContext'import {@@ -395,7 +396,12 @@ export function DataCatalogMetricScene({ name }: DataCatalogMetricSceneLogicProp{mountedTabs.includes('definition') && (<div className={tabPanelClassName('definition', activeTab)}>- <MetricMetadata metric={metric} onSaveUnit={(unit) => confirmAndUpdate({ unit })} />+ <MetricMetadata+ metric={metric}+ saving={mutating}+ onSaveUnit={(unit) => confirmAndUpdate({ unit })}+ onSaveOwner={(owner) => updateMetric({ owner })}+ /><MetricDefinitionmetric={metric}@@ -490,10 +496,14 @@ function StatusRow({ metric }: { metric: DataCatalogMetricApi }): JSX.Element {function MetricMetadata({metric,+ saving,onSaveUnit,+ onSaveOwner,}: {metric: DataCatalogMetricApi+ saving: booleanonSaveUnit: (unit: string) => void+ onSaveOwner: (owner: string | null) => void}): JSX.Element {const showProvenance = metric.created_source === 'ai_generated'@@ -501,7 +511,10 @@ function MetricMetadata({<div className="flex flex-col gap-3"><StatusRow metric={metric} /><div className="grid grid-cols-2 gap-x-8 gap-y-2 text-sm max-w-2xl">- <MetadataItem label="Owner" value={metric.owner || 'Unassigned'} />+ <MetadataItem+ label="Owner"+ value={<MetricOwnerSelect owner={metric.owner} loading={saving} onChange={onSaveOwner} />}+ /><MetadataItem label="Approved by" value={metric.approved_by?.email || 'Not approved'} /><MetadataItemlabel="Approved at"diff --git a/products/data_catalog/frontend/components/MetricOwnerSelect.tsx b/products/data_catalog/frontend/components/MetricOwnerSelect.tsxnew file mode 100644index 000000000000..f5a081f50f62--- /dev/null+++ b/products/data_catalog/frontend/components/MetricOwnerSelect.tsx@@ -0,0 +1,32 @@+import { LemonButton } from '@posthog/lemon-ui'++import { MemberSelect } from 'lib/components/MemberSelect'++export function MetricOwnerSelect({+ owner,+ loading,+ disabledReason,+ onChange,+}: {+ owner: string | null | undefined+ loading: boolean+ disabledReason?: string+ onChange: (owner: string | null) => void+}): JSX.Element {+ return (+ <MemberSelect value={null} defaultLabel="Unassigned" onChange={(user) => onChange(user?.email ?? null)}>+ {() => (+ <LemonButton+ type="tertiary"+ size="small"+ className="-ml-2 -my-1.5"+ loading={loading}+ disabledReason={disabledReason}+ data-attr="data-catalog-metric-owner-select"+ >+ {owner || 'Unassigned'}+ </LemonButton>+ )}+ </MemberSelect>+ )+}diff --git a/products/data_catalog/frontend/generated/api.schemas.ts b/products/data_catalog/frontend/generated/api.schemas.tsindex 58f20c727eb7..8efa448a7c1f 100644--- a/products/data_catalog/frontend/generated/api.schemas.ts+++ b/products/data_catalog/frontend/generated/api.schemas.ts@@ -177,10 +177,10 @@ export interface DataCatalogMetricApi {*/unit?: string/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner: string | null+ owner?: string | null/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullable@@ -280,10 +280,10 @@ export interface DataCatalogMetricCreateApi {*/unit?: string/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner: string | null+ owner?: string | null/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullable@@ -407,10 +407,10 @@ export interface PatchedDataCatalogMetricApi {*/unit?: string/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner?: string | null+ owner?: string | null/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullablediff --git a/products/data_catalog/frontend/generated/api.zod.ts b/products/data_catalog/frontend/generated/api.zod.tsindex 2e4ccb3a3445..62f893ddc720 100644--- a/products/data_catalog/frontend/generated/api.zod.ts+++ b/products/data_catalog/frontend/generated/api.zod.ts@@ -77,6 +77,12 @@ export const DataCatalogMetricsCreateBody = /* @__PURE__ */ zod.max(dataCatalogMetricsCreateBodyUnitMax).optional().describe('Unit of the result, e.g. usd, percent, cents.'),+ owner: zod+ .email()+ .nullish()+ .describe(+ "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ ),definition: zod.record(zod.string(), zod.unknown()).nullish()@@ -166,6 +172,12 @@ export const DataCatalogMetricsUpdateBody = /* @__PURE__ */ zod.object({.max(dataCatalogMetricsUpdateBodyUnitMax).optional().describe('Unit of the result, e.g. usd, percent, cents.'),+ owner: zod+ .email()+ .nullish()+ .describe(+ "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ ),definition: zod.record(zod.string(), zod.unknown()).nullish()@@ -248,6 +260,12 @@ export const DataCatalogMetricsPartialUpdateBody = /* @__PURE__ */ zod.object({.max(dataCatalogMetricsPartialUpdateBodyUnitMax).optional().describe('Unit of the result, e.g. usd, percent, cents.'),+ owner: zod+ .email()+ .nullish()+ .describe(+ "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ ),definition: zod.record(zod.string(), zod.unknown()).nullish()diff --git a/products/data_catalog/frontend/metricsLogic.test.ts b/products/data_catalog/frontend/metricsLogic.test.tsindex c84925f3f7ed..1609fa5cb57b 100644--- a/products/data_catalog/frontend/metricsLogic.test.ts+++ b/products/data_catalog/frontend/metricsLogic.test.ts@@ -14,6 +14,7 @@ import {dataCatalogMetricsCreate,dataCatalogMetricsDestroy,dataCatalogMetricsList,+ dataCatalogMetricsPartialUpdate,} from './generated/api'import type { DataCatalogMetricApi } from './generated/api.schemas'import { metricsLogic } from './metricsLogic'@@ -60,6 +61,7 @@ jest.mock('./generated/api', () => ({dataCatalogMetricsDestroy: jest.fn(),dataCatalogMetricsBulkApproveCreate: jest.fn(),dataCatalogMetricsBulkDeleteCreate: jest.fn(),+ dataCatalogMetricsPartialUpdate: jest.fn(),}))function buildMetric(overrides: Partial<DataCatalogMetricApi> = {}): DataCatalogMetricApi {@@ -103,6 +105,20 @@ describe('metricsLogic', () => {expect(logic.values.allMetrics[0].status).toEqual('approved')})+ it('saves the new owner and replaces the row with the response', async () => {+ ;(dataCatalogMetricsPartialUpdate as jest.Mock).mockResolvedValue(+ buildMetric({ owner: '[email protected]' })+ )++ logic.actions.setMetricOwner('weekly_active_users', '[email protected]')+ await expectLogic(logic).toFinishAllListeners()++ expect(dataCatalogMetricsPartialUpdate).toHaveBeenCalledWith('1', 'weekly_active_users', {+ owner: '[email protected]',+ })+ expect(logic.values.allMetrics[0].owner).toEqual('[email protected]')+ })+it('leaves the row untouched and surfaces refresh when approve returns 409', async () => {;(dataCatalogMetricsApproveCreate as jest.Mock).mockRejectedValue(new ApiError('drifted', 409))diff --git a/products/data_catalog/frontend/metricsLogic.tsx b/products/data_catalog/frontend/metricsLogic.tsxindex bd64af3454ec..e6c497b1126b 100644--- a/products/data_catalog/frontend/metricsLogic.tsx+++ b/products/data_catalog/frontend/metricsLogic.tsx@@ -19,6 +19,7 @@ import {dataCatalogMetricsBulkDeleteCreate,dataCatalogMetricsDestroy,dataCatalogMetricsList,+ dataCatalogMetricsPartialUpdate,dataCatalogMetricsRefreshFromInsightCreate,} from './generated/api'import type { DataCatalogMetricApi, DataCatalogMetricBulkSkipApi } from './generated/api.schemas'@@ -157,6 +158,13 @@ export interface metricsLogicActions {setFilters: (filters: Partial<MetricsFilters>) => {filters: Partial<MetricsFilters>}+ setMetricOwner: (+ name: string,+ owner: string | null+ ) => {+ name: string+ owner: string | null+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -185,6 +193,7 @@ export const metricsLogic = kea<metricsLogicType>([approveMetric: (name: string) => ({ name }),refreshMetricFromInsight: (name: string) => ({ name }),deleteMetric: (name: string) => ({ name }),+ setMetricOwner: (name: string, owner: string | null) => ({ name, owner }),setActionInFlight: (name: string, inFlight: boolean) => ({ name, inFlight }),bulkApproveMetrics: (names: string[], onSuccess?: () => void) => ({ names, onSuccess }),bulkDeleteMetrics: (names: string[], onSuccess?: () => void) => ({ names, onSuccess }),@@ -369,6 +378,21 @@ export const metricsLogic = kea<metricsLogicType>([actions.setActionInFlight(name, false)}},+ setMetricOwner: async ({ name, owner }) => {+ if (values.bulkActionInFlight || values.actionsInFlight[name]) {+ return+ }+ actions.setActionInFlight(name, true)+ try {+ const saved = await dataCatalogMetricsPartialUpdate(projectId(), name, { owner })+ actions.loadMetricsSuccess(values.allMetrics.map((metric) => (metric.name === name ? saved : metric)))+ lemonToast.success('Owner changed')+ } catch (error) {+ lemonToast.error(apiErrorDetail(error) || 'Could not change the owner. Try again.')+ } finally {+ actions.setActionInFlight(name, false)+ }+ },deleteMetric: async ({ name }) => {if (values.bulkActionInFlight || values.actionsInFlight[name]) {returndiff --git a/products/data_catalog/frontend/tabs/MetricsTab.tsx b/products/data_catalog/frontend/tabs/MetricsTab.tsxindex 888482c0df41..543ad60fc6de 100644--- a/products/data_catalog/frontend/tabs/MetricsTab.tsx+++ b/products/data_catalog/frontend/tabs/MetricsTab.tsx@@ -17,6 +17,7 @@ import { Tooltip } from 'lib/lemon-ui/Tooltip'import { urls } from 'scenes/urls'import { METRIC_BULK_MAX, compareText, humanizeDefinitionKind, metricCount, reportCatalogTableSorted } from '../common'+import { MetricOwnerSelect } from '../components/MetricOwnerSelect'import type { DataCatalogMetricApi } from '../generated/api.schemas'import { BulkMetricAction, MetricStatusFilter, metricsLogic } from '../metricsLogic'@@ -73,6 +74,7 @@ export function MetricsTab(): JSX.Element {approveMetric,refreshMetricFromInsight,deleteMetric,+ setMetricOwner,bulkApproveMetrics,bulkDeleteMetrics,} = useActions(metricsLogic)@@ -177,7 +179,14 @@ export function MetricsTab(): JSX.Element {{title: 'Owner',key: 'owner',- render: (_, metric) => metric.owner || <span className="text-secondary">Unassigned</span>,+ render: (_, metric) => (+ <MetricOwnerSelect+ owner={metric.owner}+ loading={!!actionsInFlight[metric.name]}+ disabledReason={bulkBusyReason}+ onChange={(owner) => setMetricOwner(metric.name, owner)}+ />+ ),sorter: (a, b) => compareText(a.owner, b.owner),},createdAtColumn<DataCatalogMetricApi>() as LemonTableColumns<DataCatalogMetricApi>[number],diff --git a/products/data_catalog/mcp/tools.yaml b/products/data_catalog/mcp/tools.yamlindex 4cf5dc97d817..f787d516750b 100644--- a/products/data_catalog/mcp/tools.yaml+++ b/products/data_catalog/mcp/tools.yaml@@ -206,7 +206,9 @@ tools:under 300 characters: what the number is and its grain. Leave out source tables or views, lineage, columnlists, and comparisons with other metrics. When editing 'definition', rewrite 'reasoning' to say why the newdefinition is shaped this way, in 1-3 short sentences: the main design decisions and trade-offs. It is not a- changelog: leave out what changed, the use case, who asked, and run results.+ changelog: leave out what changed, the use case, who asked, and run results. Set 'owner' to the email of a+ member of this organization to reassign the metric, for example when its owner left. Changing the owner+ keeps the metric's approval.exclude_params:- created_sourceinject_body:diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 757751ff955d..2e2f2a6ba36e 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -4360,7 +4360,7 @@}},"data-catalog-metric-update": {- "description": "Update a metric's fields. 'name' picks the metric to update. Editing an approved metric's definition, description, unit, or name resets it to 'proposed' (it must be re-approved by a human). Pass 'new_name' to rename the metric: the old name is freed for reuse, and anything that referenced it (saved SQL, run URLs, later tool calls) must switch to the new name. When editing 'description', keep it to 1-2 short sentences under 300 characters: what the number is and its grain. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. When editing 'definition', rewrite 'reasoning' to say why the new definition is shaped this way, in 1-3 short sentences: the main design decisions and trade-offs. It is not a changelog: leave out what changed, the use case, who asked, and run results.",+ "description": "Update a metric's fields. 'name' picks the metric to update. Editing an approved metric's definition, description, unit, or name resets it to 'proposed' (it must be re-approved by a human). Pass 'new_name' to rename the metric: the old name is freed for reuse, and anything that referenced it (saved SQL, run URLs, later tool calls) must switch to the new name. When editing 'description', keep it to 1-2 short sentences under 300 characters: what the number is and its grain. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. When editing 'definition', rewrite 'reasoning' to say why the new definition is shaped this way, in 1-3 short sentences: the main design decisions and trade-offs. It is not a changelog: leave out what changed, the use case, who asked, and run results. Set 'owner' to the email of a member of this organization to reassign the metric, for example when its owner left. Changing the owner keeps the metric's approval.","category": "Data catalog","feature": "data_catalog","summary": "Update a catalog metric",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 48c065728450..f88c952498a9 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4375,7 +4375,7 @@}},"data-catalog-metric-update": {- "description": "Update a metric's fields. 'name' picks the metric to update. Editing an approved metric's definition, description, unit, or name resets it to 'proposed' (it must be re-approved by a human). Pass 'new_name' to rename the metric: the old name is freed for reuse, and anything that referenced it (saved SQL, run URLs, later tool calls) must switch to the new name. When editing 'description', keep it to 1-2 short sentences under 300 characters: what the number is and its grain. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. When editing 'definition', rewrite 'reasoning' to say why the new definition is shaped this way, in 1-3 short sentences: the main design decisions and trade-offs. It is not a changelog: leave out what changed, the use case, who asked, and run results.",+ "description": "Update a metric's fields. 'name' picks the metric to update. Editing an approved metric's definition, description, unit, or name resets it to 'proposed' (it must be re-approved by a human). Pass 'new_name' to rename the metric: the old name is freed for reuse, and anything that referenced it (saved SQL, run URLs, later tool calls) must switch to the new name. When editing 'description', keep it to 1-2 short sentences under 300 characters: what the number is and its grain. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. When editing 'definition', rewrite 'reasoning' to say why the new definition is shaped this way, in 1-3 short sentences: the main design decisions and trade-offs. It is not a changelog: leave out what changed, the use case, who asked, and run results. Set 'owner' to the email of a member of this organization to reassign the metric, for example when its owner left. Changing the owner keeps the metric's approval.","category": "Data catalog","feature": "data_catalog","summary": "Update a catalog metric",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 170ec6ffe9de..5bafbf3868ba 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -29816,10 +29816,10 @@ export namespace Schemas {*/unit?: string;/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner: string | null;+ owner?: string | null;/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullable@@ -29961,10 +29961,10 @@ export namespace Schemas {*/unit?: string;/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner: string | null;+ owner?: string | null;/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullable@@ -85085,10 +85085,10 @@ export namespace Schemas {*/unit?: string;/**- * Email of the human accountable for this metric, or null.+ * Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval.* @nullable*/- readonly owner?: string | null;+ owner?: string | null;/*** Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.* @nullablediff --git a/services/mcp/src/generated/data_catalog/api.ts b/services/mcp/src/generated/data_catalog/api.tsindex ae0499c6755e..94968a8c08e2 100644--- a/services/mcp/src/generated/data_catalog/api.ts+++ b/services/mcp/src/generated/data_catalog/api.ts@@ -135,6 +135,12 @@ export const DataCatalogMetricsCreateBody = () => zod.max(dataCatalogMetricsCreateBodyUnitMax).optional().describe('Unit of the result, e.g. usd, percent, cents.'),+ owner: zod+ .email()+ .nullish()+ .describe(+ "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ ),definition: zod.record(zod.string(), zod.unknown()).nullish()@@ -240,6 +246,12 @@ export const DataCatalogMetricsPartialUpdateBody = () => zod.object({.max(dataCatalogMetricsPartialUpdateBodyUnitMax).optional().describe('Unit of the result, e.g. usd, percent, cents.'),+ owner: zod+ .email()+ .nullish()+ .describe(+ "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ ),definition: zod.record(zod.string(), zod.unknown()).nullish()diff --git a/services/mcp/src/tools/generated/data_catalog.ts b/services/mcp/src/tools/generated/data_catalog.tsindex b47cc54d5894..9fce2eaad93a 100644--- a/services/mcp/src/tools/generated/data_catalog.ts+++ b/services/mcp/src/tools/generated/data_catalog.ts@@ -311,6 +311,9 @@ const dataCatalogMetricCreate = (): ToolBase<if (params.unit !== undefined) {body['unit'] = params.unit}+ if (params.owner !== undefined) {+ body['owner'] = params.owner+ }if (params.definition !== undefined) {body['definition'] = params.definition}@@ -473,6 +476,9 @@ const dataCatalogMetricUpdate = (): ToolBase<if (params.unit !== undefined) {body['unit'] = params.unit}+ if (params.owner !== undefined) {+ body['owner'] = params.owner+ }if (params.definition !== undefined) {body['definition'] = params.definition}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-create.jsonindex 0a282056ae8a..fbe469a8c31b 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-create.json@@ -55,6 +55,19 @@"description": "Set to true only after the user explicitly agreed to overwrite the live metric that already holds this name. Leave it unset on the first call.","type": "boolean"},+ "owner": {+ "anyOf": [+ {+ "format": "email",+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ },"reasoning": {"description": "Why the definition is shaped this way, in 1-3 short sentences. Name the main design decisions and trade-offs: the source table or view, a filter or exclusion, the grain, an approximation. Leave out the use case, who asked, run results, validation figures, and edit history.","type": "string"diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-update.jsonindex 43a1f85dafc9..e19f28113a78 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/data-catalog-metric-update.json@@ -53,6 +53,19 @@"pattern": "^[A-Za-z][A-Za-z0-9_]*$","type": "string"},+ "owner": {+ "anyOf": [+ {+ "format": "email",+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Email of the human accountable for this metric, or null. Set it to the email of a member of this organization to reassign the metric, or to null to clear it. Changing the owner keeps the metric's approval."+ },"reasoning": {"description": "Why the definition is shaped this way, in 1-3 short sentences. Name the main design decisions and trade-offs: the source table or view, a filter or exclusion, the grain, an approximation. Leave out the use case, who asked, run results, validation figures, and edit history.","type": "string"