Skip to content

fix(cdp): clear empty event ingestion filters#2

Open
lordspline wants to merge 3 commits into
masterfrom
capy/fix-empty-event-filter-config
Open

fix(cdp): clear empty event ingestion filters#2
lordspline wants to merge 3 commits into
masterfrom
capy/fix-empty-event-filter-config

Conversation

@lordspline

@lordspline lordspline commented Jun 17, 2026

Copy link
Copy Markdown

Problem

Event ingestion filtering let users create drop rules, but deleting the last rule left the saved filter stuck because the UI treated the empty editor state as invalid instead of an intentional delete-all action.

Fixes PostHog#62507.

Changes

  • Serialize filter trees with no condition leaves as a disabled empty config: mode=disabled, filter_tree=null, and no test cases.
  • Keep partially completed non-empty conditions invalid so inline validation still reports All conditions must have a value.
  • Normalize backend API/model persistence the same way so direct API saves of empty trees disable saved filters without changing tenant scoping or ingestion lookup behavior.
  • Wrap the event filter upsert validation/save in a narrow transaction so invalid requests do not leave behind partial configs.
  • Rehydrate filter_tree=null responses into the empty editor group so users can immediately add new filters again.

How did you test this code?

  • Agent ran hogli test frontend/src/scenes/data-pipelines/event-filtering/eventFilterLogic.test.ts.
  • Agent ran hogli test posthog/api/test/test_event_filter_config.py posthog/models/test/test_event_filter_config.py.
  • Agent ran ruff check posthog/api/event_filter_config.py posthog/models/event_filter_config.py posthog/api/test/test_event_filter_config.py posthog/models/test/test_event_filter_config.py.
  • Agent ran pnpm exec oxlint --quiet frontend/src/scenes/data-pipelines/event-filtering/eventFilterLogic.ts frontend/src/scenes/data-pipelines/event-filtering/eventFilterLogic.test.ts.
  • Agent verified the running UI flow: create a dry-run event filter, save it, remove the final condition, save again, repeat save, and confirm the API persisted mode=disabled, filter_tree=null, and test_cases=[].
  • Agent attempted pnpm --filter=@posthog/frontend typescript:check; it fails before reaching this change because the local checkout is missing generated Kea type files in unrelated paths such as src/exporter/ExporterLoginType and src/layout/FeaturePreviews/featurePreviewsLogicType.

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

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No docs update needed; this preserves the existing event ingestion filtering UI/API shape and fixes delete-all persistence semantics.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Captain Capy implemented and verified this issue end to end. The key decision was to distinguish empty filter trees (intentional delete-all) from non-empty condition leaves with empty values (incomplete input), then enforce that semantic in both frontend serialization and backend persistence.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@lordspline lordspline added the capy Generated by capy.ai label Jun 17, 2026 — with Capy AI

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Added 1 comment

Comment thread posthog/models/event_filter_config.py Outdated
lordspline and others added 2 commits June 17, 2026 08:12
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Event ingestion filtering doesn't allow you to delete the filters

1 participant