:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-management): recover property definition id for View link (#68347)
posthog[bot]6df530713c84
diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.tsxindex f663c995b9cc..36f017692a11 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.tsx@@ -89,7 +89,7 @@ function Header({{state === DefinitionPopoverState.View && (<div className="definition-popover-header-row-buttons flex gap-4 text-[0.8125rem] click-outside-block">{!hideEdit && isViewable && <Link onClick={onEdit}>Edit</Link>}- {!hideView && isViewable && (+ {!hideView && isViewable && viewFullDetailUrl && (<Linktarget={openDetailInNewTab ? '_blank' : undefined}to={viewFullDetailUrl}diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsxindex 12bc6f17d07d..8147ed374d8f 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx@@ -663,7 +663,7 @@ function DefinitionEdit(): JSX.Element {)}<LemonDivider className="DefinitionPopover mt-0" /><div className="flex items-center justify-between gap-2 click-outside-block">- {!hideView && isViewable && type !== TaxonomicFilterGroupType.Events ? (+ {!hideView && isViewable && viewFullDetailUrl && type !== TaxonomicFilterGroupType.Events ? (<LemonButtonsideIcon={<IconOpenInNew style={{ marginLeft: 4, fontSize: '1rem' }} />}disabledReason={definitionLoading ? 'Loading…' : undefined}diff --git a/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.test.ts b/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.test.tsindex 1044249b9ec0..935dc1d3d4b0 100644--- a/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.test.ts+++ b/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.test.ts@@ -224,6 +224,29 @@ describe('definitionPopoverLogic', () => {}})})++ it('saves a name-only property against the id recovered from the model', async () => {+ // A pinned/default property arrives as { name } with no id; Save used to PATCH+ // /property_definitions/undefined. resolvedDefinition hydrates the recovered id.+ propertyDefinitionsModel.actions.updatePropertyDefinitions({+ [`event/${mockEventPropertyDefinition.name}`]: mockEventPropertyDefinition as PropertyDefinition,+ })++ logic = definitionPopoverLogic({ type: TaxonomicFilterGroupType.EventProperties })+ logic.mount()++ await expectLogic(logic, async () => {+ logic.actions.setDefinition({ name: mockEventPropertyDefinition.name })+ logic.actions.setPopoverState(DefinitionPopoverState.Edit)+ logic.actions.setLocalDefinition({ description: 'edited' })+ logic.actions.handleSave({})+ }).toDispatchActions(['handleSaveSuccess'])++ expect(api.update).toHaveBeenCalledWith(+ `api/projects/${MOCK_TEAM_ID}/property_definitions/${mockEventPropertyDefinition.id}`,+ expect.objectContaining({ description: 'edited' })+ )+ })})it('add tags', async () => {@@ -354,5 +377,39 @@ describe('definitionPopoverLogic', () => {})})})++ describe('recovers a missing property id from the definitions model', () => {+ // Pinned/default property items (e.g. seeded $current_url, email) are stored+ // as { name } with no id, so viewFullDetailUrl used to build+ // /data-management/properties/undefined. It must recover the saved id from+ // propertyDefinitionsModel so the View link resolves to the real property.+ // Per-type mapping lives in resolvePropertyDefinitionId (tested in utils.test);+ // this asserts the selector wires the recovered id into the URL and guards it.+ it('resolves the View URL for a name-only property from the model', async () => {+ propertyDefinitionsModel.actions.updatePropertyDefinitions({+ [`event/${mockEventPropertyDefinition.name}`]: mockEventPropertyDefinition as PropertyDefinition,+ })++ logic = definitionPopoverLogic({ type: TaxonomicFilterGroupType.EventProperties })+ logic.mount()++ await expectLogic(logic, () => {+ logic.actions.setDefinition({ name: mockEventPropertyDefinition.name })+ })+ .toDispatchActions(['setDefinitionSuccess'])+ .toMatchValues({ viewFullDetailUrl: urls.propertyDefinition(mockEventPropertyDefinition.id) })+ })++ it('stays undefined when the property id cannot be resolved', async () => {+ logic = definitionPopoverLogic({ type: TaxonomicFilterGroupType.EventProperties })+ logic.mount()++ await expectLogic(logic, () => {+ logic.actions.setDefinition({ name: 'property-with-no-saved-definition' })+ })+ .toDispatchActions(['setDefinitionSuccess'])+ .toMatchValues({ viewFullDetailUrl: undefined })+ })+ })})})diff --git a/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.ts b/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.tsindex 091d9124a93f..974ec1030c12 100644--- a/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.ts+++ b/frontend/src/lib/components/DefinitionPopover/definitionPopoverLogic.ts@@ -4,6 +4,7 @@ import { loaders } from 'kea-loaders'import api from 'lib/api'import { getSingularType } from 'lib/components/DefinitionPopover/utils'+import { resolvePropertyDefinitionId } from 'lib/components/PropertyFilters/utils'import { getDataWarehouseItemWithFieldDefaults } from 'lib/components/TaxonomicFilter/dataWarehouseItemUtils'import { TaxonomicDefinitionTypes, TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'@@ -14,7 +15,7 @@ import { urls } from 'scenes/urls'import { actionsModel } from '~/models/actionsModel'import { cohortsModel } from '~/models/cohortsModel'-import { updatePropertyDefinitions } from '~/models/propertyDefinitionsModel'+import { propertyDefinitionsModel, updatePropertyDefinitions } from '~/models/propertyDefinitionsModel'import { ActionType, CohortType, EventDefinition, PropertyDefinition } from '~/types'import { DataWarehouseTableForInsight } from 'products/data_warehouse/frontend/types'@@ -44,7 +45,9 @@ export interface DefinitionPopoverLogicProps {export const definitionPopoverLogic = kea<definitionPopoverLogicType>([props({} as DefinitionPopoverLogicProps),path(['lib', 'components', 'DefinitionPanel', 'definitionPopoverLogic']),- connect(() => ({ values: [teamLogic, ['currentProjectId']] })),+ connect(() => ({+ values: [teamLogic, ['currentProjectId'], propertyDefinitionsModel, ['getPropertyDefinition']],+ })),actions(({ values, props }) => ({setDefinition: (item: Partial<TaxonomicDefinitionTypes>) => ({item,@@ -66,8 +69,10 @@ export const definitionPopoverLogic = kea<definitionPopoverLogicType>([return {}}+ // resolvedDefinition carries the recovered id for name-only pinned/default+ // property items, so Save PATCHes the real definition instead of /undefined.let definition = {- ...values.definition,+ ...values.resolvedDefinition,...values.localDefinition,} as TaxonomicDefinitionTypescache.startTime = performance.now()@@ -229,21 +234,43 @@ export const definitionPopoverLogic = kea<definitionPopoverLogicType>([(s) => [s.type],(type) => type === TaxonomicFilterGroupType.DataWarehousePersonProperties,],+ resolvedDefinition: [+ (s) => [s.definition, s.isProperty, s.type, s.getPropertyDefinition],+ (definition, isProperty, type, getPropertyDefinition): Partial<TaxonomicDefinitionTypes> => {+ // Pinned/default property items are stored as { name } only. Hydrate them with the+ // saved definition id recovered from propertyDefinitionsModel so View, Edit and Save+ // all operate on a complete definition (and self-heal as the model loads) rather+ // than hitting /data-management/properties/undefined.+ if (isProperty && definition && !(definition as PropertyDefinition).id) {+ const id = resolvePropertyDefinitionId(+ definition as PropertyDefinition,+ type as TaxonomicFilterGroupType,+ getPropertyDefinition+ )+ if (id) {+ // Cast because the union has numeric-id members (ActionType/CohortType);+ // this branch only runs for property definitions (string id).+ return { ...definition, id } as Partial<TaxonomicDefinitionTypes>+ }+ }+ return definition+ },+ ],viewFullDetailUrl: [- (s) => [s.definition, s.isAction, s.isEvent, s.isProperty, s.isCohort],- (definition, isAction, isEvent, isProperty, isCohort) => {+ (s) => [s.resolvedDefinition, s.isAction, s.isEvent, s.isProperty, s.isCohort],+ (resolvedDefinition, isAction, isEvent, isProperty, isCohort) => {if (isAction) {- // Action Definitions- return urls.action((definition as ActionType).id)+ const id = (resolvedDefinition as ActionType).id+ return id != null ? urls.action(id) : undefined} else if (isEvent) {- // Event Definitions- return urls.eventDefinition((definition as EventDefinition).id)+ const id = (resolvedDefinition as EventDefinition).id+ return id ? urls.eventDefinition(id) : undefined} else if (isProperty) {- // Property Definitions- return urls.propertyDefinition((definition as PropertyDefinition).id)+ const id = (resolvedDefinition as PropertyDefinition).id+ return id ? urls.propertyDefinition(id) : undefined} else if (isCohort) {- // Cohort- return urls.cohort((definition as CohortType).id)+ const id = (resolvedDefinition as CohortType).id+ return id != null ? urls.cohort(id) : undefined}return undefined},diff --git a/frontend/src/lib/components/PropertyFilters/utils.test.ts b/frontend/src/lib/components/PropertyFilters/utils.test.tsindex 346510b36844..9f6fe14eeb61 100644--- a/frontend/src/lib/components/PropertyFilters/utils.test.ts+++ b/frontend/src/lib/components/PropertyFilters/utils.test.ts@@ -7,9 +7,11 @@ import {isValidPropertyFilter,normalizePropertyFilterValue,propertyFilterTypeToTaxonomicFilterType,+ resolvePropertyDefinitionId,taxonomicFilterTypeToPropertyFilterType,} from 'lib/components/PropertyFilters/utils'+import { propertyDefinitionsModelType } from '~/models/propertyDefinitionsModelType'import { BreakdownFilter } from '~/queries/schema/schema-general'import {@@ -18,6 +20,8 @@ import {ElementPropertyFilter,EmptyPropertyFilter,FilterLogicalOperator,+ PropertyDefinition,+ PropertyDefinitionType,PropertyFilterType,PropertyGroupFilter,PropertyOperator,@@ -451,3 +455,43 @@ describe('createDefaultPropertyFilter()', () => {expect(result).toEqual(expect.objectContaining({ key: 'user.email', value: null }))})})++describe('resolvePropertyDefinitionId()', () => {+ const modelWith = (+ byKey: Record<string, PropertyDefinition>+ ): propertyDefinitionsModelType['values']['getPropertyDefinition'] =>+ ((name, type) =>+ byKey[`${type}/${name}`] ?? null) as propertyDefinitionsModelType['values']['getPropertyDefinition']++ it('returns the id already on the definition without consulting the model', () => {+ const getPropertyDefinition = jest.fn()+ expect(+ resolvePropertyDefinitionId(+ { id: 'abc', name: '$browser' },+ TaxonomicFilterGroupType.EventProperties,+ getPropertyDefinition as unknown as propertyDefinitionsModelType['values']['getPropertyDefinition']+ )+ ).toBe('abc')+ expect(getPropertyDefinition).not.toHaveBeenCalled()+ })++ // Recovers a name-only pinned/default property's id from the model, keyed by the+ // group type mapped through to a PropertyDefinitionType — the /properties/undefined regression.+ it.each([+ [TaxonomicFilterGroupType.EventProperties, PropertyDefinitionType.Event, '$current_url', 'event-url-id'],+ [TaxonomicFilterGroupType.PersonProperties, PropertyDefinitionType.Person, 'email', 'person-email-id'],+ ])('recovers a name-only %s id from the model', (groupType, defType, name, id) => {+ const get = modelWith({ [`${defType}/${name}`]: { id, name } as PropertyDefinition })+ expect(resolvePropertyDefinitionId({ name } as PropertyDefinition, groupType, get)).toBe(id)+ })++ it('returns undefined when the model has no matching definition', () => {+ expect(+ resolvePropertyDefinitionId(+ { name: 'never-loaded' } as PropertyDefinition,+ TaxonomicFilterGroupType.EventProperties,+ () => null+ )+ ).toBeUndefined()+ })+})diff --git a/frontend/src/lib/components/PropertyFilters/utils.ts b/frontend/src/lib/components/PropertyFilters/utils.tsindex 43682048bb99..4a678848a9e7 100644--- a/frontend/src/lib/components/PropertyFilters/utils.ts+++ b/frontend/src/lib/components/PropertyFilters/utils.ts@@ -34,6 +34,7 @@ import {LogPropertyFilter,PersonMetadataPropertyFilter,PersonPropertyFilter,+ PropertyDefinition,PropertyDefinitionType,PropertyFilterType,PropertyFilterValue,@@ -567,6 +568,33 @@ export function taxonomicFilterTypeToPropertyFilterType(| undefined}+/**+ * Recover a property definition's id. Pinned/default taxonomic items are stored as+ * `{ name }` with no saved id, so fall back to the canonical `propertyDefinitionsModel`+ * (keyed by name + type) instead of building a link with an `undefined` id. Returns+ * `undefined` when the id can't be resolved so callers can hide the link. Shared by the+ * legacy DefinitionPopover and the quill rebuild's PreviewPane to keep them in lockstep.+ */+export function resolvePropertyDefinitionId(+ definition: Pick<PropertyDefinition, 'id' | 'name'>,+ taxonomicGroupType: TaxonomicFilterGroupType,+ getPropertyDefinition: propertyDefinitionsModelType['values']['getPropertyDefinition']+): PropertyDefinition['id'] | undefined {+ if (definition.id) {+ return definition.id+ }+ if (!definition.name) {+ return undefined+ }+ const propertyFilterType = taxonomicFilterTypeToPropertyFilterType(taxonomicGroupType)+ // `null` only when the taxonomic type has no property-filter equivalent;+ // propertyFilterTypeToPropertyDefinitionType itself is total (defaults to Event).+ const propertyDefinitionType = propertyFilterType+ ? propertyFilterTypeToPropertyDefinitionType(propertyFilterType)+ : null+ return propertyDefinitionType ? getPropertyDefinition(definition.name, propertyDefinitionType)?.id : undefined+}+export function isEmptyProperty(property: AnyPropertyFilter): boolean {return (property.value === null ||diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.test.ts b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.test.tsnew file mode 100644index 000000000000..2823efa295d8--- /dev/null+++ b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.test.ts@@ -0,0 +1,37 @@+import { urls } from 'scenes/urls'++import { propertyDefinitionsModelType } from '~/models/propertyDefinitionsModelType'+import { PropertyDefinition } from '~/types'++import { TaxonomicFilterGroup, TaxonomicFilterGroupType } from '../types'+import { resolveViewUrl } from './PreviewPane'+import { MenuFilterEntry } from './types'++// resolveViewUrl is the rebuild's separate implementation of the legacy+// definitionPopoverLogic.viewFullDetailUrl selector — no test enforces parity+// between the two. Per-type id recovery lives in (and is tested via)+// resolvePropertyDefinitionId; these cases only guard that the rebuild delegates+// to it and hides the link when nothing resolves (the /properties/undefined regression).+describe('resolveViewUrl', () => {+ const entry = (type: TaxonomicFilterGroupType, item: Partial<PropertyDefinition>): MenuFilterEntry =>+ ({ item, group: { type } as TaxonomicFilterGroup, name: String(item.name ?? '') }) as MenuFilterEntry++ it('builds the property URL from the recovered id for a name-only item', () => {+ const getPropertyDefinition = ((name) =>+ name === '$current_url'+ ? ({ name, id: 'event-url-id' } as PropertyDefinition)+ : null) as propertyDefinitionsModelType['values']['getPropertyDefinition']++ const url = resolveViewUrl(+ entry(TaxonomicFilterGroupType.EventProperties, { name: '$current_url' }),+ getPropertyDefinition+ )++ expect(url).toBe(urls.propertyDefinition('event-url-id'))+ })++ it('stays undefined when a name-only property cannot be resolved', () => {+ const url = resolveViewUrl(entry(TaxonomicFilterGroupType.EventProperties, { name: 'never-saved' }), () => null)+ expect(url).toBeUndefined()+ })+})diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsxindex 7a9f24719257..506c88036245 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx@@ -9,14 +9,17 @@* Properties / events / actions render specific extras; everything else* falls back to the shared header + description.*/+import { useValues } from 'kea'import posthog from 'posthog-js'import { IconPin } from '@posthog/icons'import { Button, cn, ScrollArea, Separator } from '@posthog/quill'+import { resolvePropertyDefinitionId } from 'lib/components/PropertyFilters/utils'import { Link } from 'lib/lemon-ui/Link'import { urls } from 'scenes/urls'+import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { ActionType, CohortType, EventDefinition, PropertyDefinition } from '~/types'import { useTaxonomicAutocompleteItemDetails } from '../headless'@@ -50,6 +53,7 @@ function PreviewEmpty(): JSX.Element {function PreviewBody({ entry }: { entry: MenuFilterEntry }): JSX.Element | null {const details = useTaxonomicAutocompleteItemDetails(entry)+ const { getPropertyDefinition } = useValues(propertyDefinitionsModel)if (!details) {return null}@@ -58,7 +62,7 @@ function PreviewBody({ entry }: { entry: MenuFilterEntry }): JSX.Element | null// in the shared hook — the hook only models scalar metadata. Same// for event first/last seen (handled later if needed).const isAction = entry.group.type === TaxonomicFilterGroupType.Actions- const viewUrl = resolveViewUrl(entry)+ const viewUrl = resolveViewUrl(entry, getPropertyDefinition)const matchedValue = getMatchedValue(entry)return (@@ -159,9 +163,14 @@ function PreviewHeader({ details, viewUrl, entry }: PreviewHeaderProps): JSX.Ele* Resolve the data-management URL for an entry. Mirrors the legacy* `definitionPopoverLogic.viewFullDetailUrl` selector — Action / Event /* Property / Cohort each have their own page; everything else returns- * `undefined` so the link is hidden.+ * `undefined` so the link is hidden. Pinned/default property items are+ * stored as `{ name }` only, so recover the saved definition id from+ * `propertyDefinitionsModel` rather than pointing at `/properties/undefined`.*/-function resolveViewUrl(entry: MenuFilterEntry): string | undefined {+export function resolveViewUrl(+ entry: MenuFilterEntry,+ getPropertyDefinition: typeof propertyDefinitionsModel.values.getPropertyDefinition+): string | undefined {const { group, item } = entryswitch (group.type) {case TaxonomicFilterGroupType.Actions: {@@ -178,7 +187,7 @@ function resolveViewUrl(entry: MenuFilterEntry): string | undefined {case TaxonomicFilterGroupType.SessionProperties:case TaxonomicFilterGroupType.EventMetadata:case TaxonomicFilterGroupType.EventFeatureFlags: {- const id = (item as PropertyDefinition).id+ const id = resolvePropertyDefinitionId(item as PropertyDefinition, group.type, getPropertyDefinition)return id ? urls.propertyDefinition(id) : undefined}case TaxonomicFilterGroupType.Cohorts:diff --git a/posthog/api/event_definition.py b/posthog/api/event_definition.pyindex 22ea46ad2aed..d9b4062b31c9 100644--- a/posthog/api/event_definition.py+++ b/posthog/api/event_definition.py@@ -1,10 +1,12 @@from __future__ import annotations+import uuidfrom collections import defaultdictfrom typing import Any, Literal, Optional, castfrom django.core.cache import cachefrom django.db.models import Manager+from django.http import Http404import orjsonimport posthoganalytics@@ -404,6 +406,13 @@ class EventDefinitionViewSet(return response.Response(serializer.data)def dangerously_get_object(self):+ # A non-UUID lookup (e.g. the literal "undefined" from a link built without a saved+ # definition id) would raise a ValueError deep in the ORM and surface as a 500. Return a+ # clean 404 instead.+ try:+ uuid.UUID(str(self.kwargs["id"]))+ except ValueError:+ raise Http404("Event definition not found.")return self._get_event_definition(id=self.kwargs["id"], team__project_id=self.project_id)def _get_event_definition(self, **filters) -> EventDefinition:diff --git a/posthog/api/test/test_event_definition.py b/posthog/api/test/test_event_definition.pyindex 02ebaa96dda5..38aca9d2d117 100644--- a/posthog/api/test/test_event_definition.py+++ b/posthog/api/test/test_event_definition.py@@ -463,6 +463,12 @@ class TestEventDefinitionAPI(APIBaseTest):response = self.client.get("/api/projects/@current/event_definitions/by_name/?name=nonexistent")assert response.status_code == status.HTTP_404_NOT_FOUND+ def test_retrieve_with_non_uuid_id_returns_404(self):+ # Links built without a saved definition id (e.g. pinned defaults) request+ # `.../event_definitions/undefined` — that must 404, not 500 with a UUID ValueError.+ response = self.client.get("/api/projects/@current/event_definitions/undefined")+ assert response.status_code == status.HTTP_404_NOT_FOUND+def test_by_name_missing_param(self):response = self.client.get("/api/projects/@current/event_definitions/by_name/")assert response.status_code == status.HTTP_400_BAD_REQUESTdiff --git a/posthog/api/test/test_property_definition.py b/posthog/api/test/test_property_definition.pyindex 255373b7354e..568d267249ee 100644--- a/posthog/api/test/test_property_definition.py+++ b/posthog/api/test/test_property_definition.py@@ -68,6 +68,12 @@ class TestPropertyDefinitionAPI(APIBaseTest):assert response.status_code == status.HTTP_200_OKassert response.json()["property_type"] == "DateTime"+ def test_retrieve_with_non_uuid_id_returns_404(self):+ # Links built without a saved definition id (e.g. pinned defaults) request+ # `.../property_definitions/undefined` — that must 404, not 500 with a UUID ValueError.+ response = self.client.get(f"/api/projects/{self.team.pk}/property_definitions/undefined")+ assert response.status_code == status.HTTP_404_NOT_FOUND+def test_list_property_definitions(self):response = self.client.get(f"/api/projects/{self.team.pk}/property_definitions/")assert response.status_code == status.HTTP_200_OKdiff --git a/posthog/taxonomy/property_definition_api.py b/posthog/taxonomy/property_definition_api.pyindex db3c4c5ce4d5..0a82b8cad18a 100644--- a/posthog/taxonomy/property_definition_api.py+++ b/posthog/taxonomy/property_definition_api.py@@ -1,10 +1,12 @@import json+import uuidimport dataclassesfrom typing import Any, Optional, Self, Union, castfrom django.db import connection, modelsfrom django.db.models import Manager, QuerySetfrom django.db.models.functions import Coalesce+from django.http import Http404from django.shortcuts import get_object_or_404from opentelemetry import trace@@ -748,6 +750,13 @@ class PropertyDefinitionViewSet(def safely_get_object(self, queryset):id = self.kwargs["id"]+ # A non-UUID lookup (e.g. the literal "undefined" from a link built without a saved+ # definition id) would raise a ValueError deep in the ORM and surface as a 500. Return a+ # clean 404 instead.+ try:+ uuid.UUID(str(id))+ except ValueError:+ raise Http404("Property definition not found.")non_enterprise_property = get_object_or_404(PropertyDefinition.objects.alias(effective_project_id=Coalesce("project_id", "team_id", output_field=models.BigIntegerField())