Skip to content

feat(flags): UX for feature flag dependencies#35284

Closed
haacked wants to merge 63 commits intomasterfrom
haacked/29016-flag-dependencies-ux
Closed

feat(flags): UX for feature flag dependencies#35284
haacked wants to merge 63 commits intomasterfrom
haacked/29016-flag-dependencies-ux

Conversation

@haacked
Copy link
Contributor

@haacked haacked commented Jul 18, 2025

See demo video:

https://www.loom.com/share/9e1213bdd7094274915bb8b6f9f83205?sid=a908b8f7-6a2d-4e8f-a7bf-86e3217d592b

Important

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Problem

We want to be able to have flags that depend on the evaluation of other flags.

Fixes #29016

Changes

  1. Adds a new flag filter property type
  2. When selecting conditions, adds a flags tab to select feature flags
  3. Allows selecting a flag value
  4. This is all hidden behind a feature flag

Did you write or update any docs for this change?

How did you test this code?

Manual testing.

haacked added 30 commits July 18, 2025 09:01
Adds a PropertyFilterType of FlagDependency (`flag`) and a property type of `Flag`
Also add a router for the new endpoint.
And related infrastructure
When a flag has multiple variants, we want to explain what `true` and `false` mean.
Prevent feature flags from creating circular dependencies when one flag
depends on another. This validation runs at the API layer when creating
or updating feature flags with flag dependencies.

- Add _check_flag_circular_dependencies method to detect cycles
- Integrate validation into validate_filters for flag properties
- Handle different property key formats ($feature/, $feature_flag/, plain)
- Add comprehensive tests for direct and indirect cycles
- Gracefully handle missing/deleted flag dependencies

Fixes #29016
- Add PropertyDefinitionType.FlagValue mapping to EventFeatureFlags in PropertiesTable
- Change groupTypeIndex from null to undefined in PropertyValue tests
- Remove unused React import and add type annotations in test-boolean-preservation
- Add PropertyFilterType.FlagDependency to TaxonomicFilterGroupType mapping
- Fix appropriateGroups reference to use filterGroups in featureFlagReleaseConditionsLogic
- Add proper type annotations for FeatureFlagGroupType and AnyPropertyFilter
Update error messages in test_validation_person_properties to reflect
that flag properties are now allowed in feature flag filters
Spread featureFlagOperatorMap last so its operators take precedence over others,
ensuring that flag dependencies show 'evaluates to' instead of 'equals'.
And document why we do it.
@haacked
Copy link
Contributor Author

haacked commented Jul 18, 2025

One of the decisions I made early was to make a flag dependency have a filter type of flag and just use the existing equals operator to mean "evaluates to", even though @dmarticus suggested using a new operator specific to flag evaluation. At the time, it seemed like a good decision because it minimal changes to the filters schema.

But now that I'm building the UI, I'm having to special case a lot to because we want equals to mean evaluates to when we display it in the UI.

It's kind of a big change but I'm thinking I should add a new operator, but I'd love some other opinions.

@PostHog PostHog deleted a comment from posthog-bot Jul 18, 2025
@PostHog PostHog deleted a comment from posthog-bot Jul 18, 2025
@PostHog PostHog deleted a comment from posthog-bot Jul 18, 2025
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

14 snapshot changes in total. 0 added, 14 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@haacked haacked force-pushed the haacked/29016-flag-dependencies-ux branch from 858cce3 to dace5dd Compare July 18, 2025 20:31
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

16 snapshot changes in total. 0 added, 16 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 4)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@haacked haacked marked this pull request as draft July 18, 2025 20:59
@dmarticus dmarticus moved this from In Review to Todo in Feature Flags Jul 18, 2025
@haacked haacked removed the request for review from a team July 18, 2025 20:59
haacked added a commit that referenced this pull request Jul 19, 2025
Implements standalone API endpoint that returns possible values for feature flags:
- Boolean flags return [true, false]
- Multivariate flags return [true, false] + variant keys
- Endpoint: /api/projects/{project_id}/flag_value/values?key={flag_id}
- Includes comprehensive test coverage and error handling
- Enables frontend flag dependency selection UI

Extracted from PR #35284 as independent deployable component.
@dmarticus dmarticus moved this from Todo to In Progress in Feature Flags Jul 28, 2025
@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

@haacked haacked self-assigned this Jul 29, 2025
@posthog-bot posthog-bot removed the stale label Jul 29, 2025
@haacked haacked closed this Jul 30, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Feature Flags Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Flag rollout condition based on another flag

2 participants