PostHog / PostHog/posthog

fix(flags): update frontend null checks to enable per-condition aggregation_group_type_index

Open
#52,024 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Context

Part of #46288 (Mixed User + Group Targeting for Feature Flags).

PR #51399 adds aggregation_group_type_index to each condition set, but currently only sets the field when the value is non-null. For person-aggregated flags, the field is left absent to preserve backward compatibility with frontend code that uses !== undefined checks.

This blocks the full per-condition aggregation vision where every condition set explicitly carries its aggregation mode (including None for person-aggregated).

Problem

~10 frontend locations use !== undefined to check aggregation_group_type_index. In JavaScript, null !== undefined is true, so adding explicit null values would cause these checks to incorrectly treat person-aggregated flags as group-aggregated.

Affected locations
File Pattern Impact
relatedFeatureFlagsLogic.ts !== undefined Flags miscategorized as group-based
experimentLogic.tsx !== undefined Always includes field in spread
featureFlagLogic.ts == undefined Early access feature creation breaks
FunnelsAdvanced.tsx != undefined Wrong text rendered
filtersToQueryNode.ts !== undefined null sent to backend unexpectedly
retentionModalLogic.ts !== undefined Group queries misidentified
funnelPathsExpansionLogic.ts != undefined Funnel paths incorrectly disabled
cleanFilters.ts != undefined Filter cleaning changes

Fix

Replace !== undefined / != undefined with != null (which catches both null and undefined) or use explicit != null checks. Then update the Python normalization to always set the field, and backfill existing flags.

Steps

  1. Fix all frontend !== undefined checks for aggregation_group_type_index to use != null
  2. Update posthog/api/feature_flag.py normalization to always set the field (remove the is not None guard)
  3. Backfill existing person-aggregated flags to have explicit aggregation_group_type_index: null on each condition set

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the listed frontend files, including relatedFeatureFlagsLogic.ts, experimentLogic.tsx, featureFlagLogic.ts, FunnelsAdvanced.tsx, and the filter and funnel logic files, then inspect posthog/api/feature_flag.py. Update the null checks, make normalization always set the field, and backfill existing person-aggregated flags so every condition set has an explicit null value.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.