Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(flags): Stop deleting flags when experiment is deleted #29090

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

havenbarnes
Copy link
Contributor

@havenbarnes havenbarnes commented Feb 21, 2025

Problem

Context: https://posthog.slack.com/archives/C06UTAJJEHM/p1740121610717549

Deleting an experiment automatically soft deletes the linked feature flag. This is not documented anywhere during experiment creation, and for flags that are pre-existing before being linked to an experiment, this is especially dangerous hidden behavior.

Changes

Remove the pre_delete hook in the feature_flag model

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Validated no more cascading flag deletion after deleting an experiment

deleted_experiment.mp4

@havenbarnes havenbarnes requested review from a team February 21, 2025 22:43
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR removes the automatic soft deletion of feature flags when experiments are deleted, addressing a potentially dangerous hidden behavior in PostHog.

  • Removed pre_delete signal handler in /posthog/models/feature_flag/feature_flag.py that was causing feature flags to be soft-deleted when associated experiments were deleted
  • Prevents unintended deletion of pre-existing feature flags that were later linked to experiments
  • Improves system predictability by removing undocumented cascading deletion behavior
  • Maintains feature flag independence from experiment lifecycle

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@nikunjy
Copy link

nikunjy commented Feb 21, 2025

nice !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants