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(feature-flags): persist false value in flag dependency conditions (#60303)

Gustavo H. Strassburger0d1a4b1a40c1
diff --git a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.test.ts b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.test.ts
index d3422362de63..a11974620b98 100644
--- a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.test.ts
+++ b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.test.ts
@@ -6,9 +6,9 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+import { AnyPropertyFilter, PropertyFilterType, PropertyFilterValue, PropertyOperator } from '~/types'
-const eventFilter = (key: string, value?: string, operator?: PropertyOperator): AnyPropertyFilter =>
+const eventFilter = (key: string, value?: PropertyFilterValue, operator?: PropertyOperator): AnyPropertyFilter =>
({
key,
type: PropertyFilterType.Event,
@@ -118,6 +118,24 @@ describe('propertyFilterLogic', () => {
const cb = await setFilterAndCheck(filter, false)
expect(cb).not.toHaveBeenCalled()
})
+
+ it.each<[string, AnyPropertyFilter, false | 0]>([
+ [
+ 'boolean false (e.g. flag dependency set to false)',
+ {
+ key: '911',
+ type: PropertyFilterType.Flag,
+ operator: PropertyOperator.FlagEvaluatesTo,
+ value: false,
+ } as AnyPropertyFilter,
+ false,
+ ],
+ ['number 0', eventFilter('$browser', 0, PropertyOperator.Exact), 0],
+ ])('calls onChange when the value is the falsy literal %s', async (_name, filter, expectedValue) => {
+ const cb = await setFilterAndCheck(filter, false)
+ expect(cb).toHaveBeenCalledTimes(1)
+ expect(cb.mock.calls[0][0][0]).toMatchObject({ value: expectedValue })
+ })
})
describe('filter IDs are stable across mutations', () => {
diff --git a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
index 5f1c516cce8f..52b4c9a67fde 100644
--- a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
+++ b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
@@ -118,7 +118,10 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>([
listeners(({ actions, props, values }) => ({
setFilter: async ({ property }) => {
- const hasValue = property?.value && !(Array.isArray(property.value) && property.value.length === 0)
+ const value = property?.value
+ const isEmpty =
+ value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)
+ const hasValue = !isEmpty
const isComplete =
hasValue || ('operator' in property && property?.operator && isOperatorFlag(property.operator))