Skip to content

: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.

fix(filters): normalize non-array propertyFilters input (#62336)

Meikel Ratz42f652a29aa6
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
index a8715aaf1211..d218b15411f5 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
@@ -182,6 +182,25 @@ describe('PropertyFilters', () => {
expect(pill?.textContent).toMatch(/Browser/)
})
+ it('does not crash when propertyFilters is a non-array (legacy / corrupted shape)', () => {
+ // Regression test for "n.map is not a function" crash. The reducer's initial-state path
+ // runs parseProperties, but the prop-change useEffect previously called setFilters directly
+ // — so any consumer (e.g. a HogFlow with an event-shaped object stored in conversion.filters)
+ // crashed the moment the picker re-rendered. PropertyFilters must tolerate the same input
+ // shapes parseProperties does: arrays, PropertyGroup objects, and dict-style objects.
+ const eventShapedObject = {
+ events: [{ id: 'user_signed_up', name: 'user_signed_up', type: 'events', order: 0 }],
+ source: 'events',
+ actions: [],
+ } as any
+
+ expect(() =>
+ renderPropertyFilters({
+ propertyFilters: eventShapedObject,
+ })
+ ).not.toThrow()
+ })
+
it('does not change reducer state when re-rendered with same filter values', () => {
const filters = [BROWSER_FILTER]
const onChange = jest.fn()
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
index 03425deebaa1..88247d487d81 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
@@ -4,6 +4,7 @@ import { BindLogic, useActions, useValues } from 'kea'
import React, { useEffect, useState } from 'react'
import { TaxonomicPropertyFilter } from 'lib/components/PropertyFilters/components/TaxonomicPropertyFilter'
+import { parseProperties } from 'lib/components/PropertyFilters/utils'
import {
AllowedProperties,
ExcludedOperators,
@@ -104,7 +105,7 @@ export function PropertyFilters({
const [allowOpenOnInsert, setAllowOpenOnInsert] = useState<boolean>(false)
useEffect(() => {
- setFilters(propertyFilters ?? [])
+ setFilters(propertyFilters ? parseProperties(propertyFilters) : [])
}, [propertyFilters, setFilters])
const displayedFilters = allowNew && editable ? filtersWithNew : filters