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(insights): skip data checks for single-step funnels (#124308)

Sam Penningtonf6f332d18aa1
diff --git a/products/product_analytics/backend/chart_events.py b/products/product_analytics/backend/chart_events.py
index af6c5e550bfb..0637c900d0f8 100644
--- a/products/product_analytics/backend/chart_events.py
+++ b/products/product_analytics/backend/chart_events.py
@@ -4,6 +4,7 @@ from datetime import datetime
from typing import Any, cast
from pydantic import ValidationError
+from rest_framework.exceptions import ValidationError as DRFValidationError
from posthog.schema import ActionsNode, EventsNode, GroupNode, HogQLQueryModifiers
@@ -88,7 +89,11 @@ def chart_events(query: Mapping[str, Any], team: Team, user: User) -> ChartEvent
# A data warehouse series reads no events.
if not runner.query.series or not all(_reads_events(series) for series in runner.query.series):
return None
- runner.validate()
+ try:
+ runner.validate()
+ except DRFValidationError:
+ # The chart cannot run the query either, such as a funnel with one step.
+ return None
database = runner.shared_database
filters: list[tuple[str | None, ast.Expr, QueryDateRange]] = []
for chart_query, date_range in _chart_queries(runner):
diff --git a/products/product_analytics/backend/tests/test_chart_events.py b/products/product_analytics/backend/tests/test_chart_events.py
index 6945a619a3dd..d6f561594088 100644
--- a/products/product_analytics/backend/tests/test_chart_events.py
+++ b/products/product_analytics/backend/tests/test_chart_events.py
@@ -59,6 +59,9 @@ class TestChartEvents(BaseTest):
def test_finds_the_events_the_chart_reads(self, _name: str, source: dict[str, Any]) -> None:
assert chart_events(source, self.team, self.user) is not None
+ def test_does_not_support_a_funnel_with_one_step(self) -> None:
+ assert chart_events({"kind": "FunnelsQuery", "series": [SERIES]}, self.team, self.user) is None
+
@time_machine.travel(NOW, tick=False)
class TestChartEventsCounts(ClickhouseTestMixin, BaseTest):
diff --git a/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.test.ts b/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.test.ts
index 9ca7c6bbb151..9729b3fb0956 100644
--- a/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.test.ts
+++ b/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.test.ts
@@ -166,6 +166,7 @@ describe('insightDataChecksLogic', () => {
math: 'total',
properties: [onChrome],
},
+ { kind: NodeKind.EventsNode, event: 'paid' },
],
dateRange: { date_from: '-30d' },
filterTestAccounts: true,
@@ -183,6 +184,17 @@ describe('insightDataChecksLogic', () => {
expect(sentSources.at(-1)).toEqual(source)
})
+ it('does not check a funnel with one step, because the chart runs no query for it', async () => {
+ dataChecks.mockImplementation(answer([200, checksOf('passed')]))
+ const source = { kind: NodeKind.FunnelsQuery, series: [{ kind: NodeKind.EventsNode, event: 'signed up' }] }
+ insightDataLogic(props).actions.setQuery({ kind: NodeKind.InsightVizNode, source } as InsightVizNode)
+
+ await expectLogic(logic, turnTheFlagOn).toFinishAllListeners()
+
+ expect(dataChecks).not.toHaveBeenCalled()
+ expect(logic.values.status).toBe('unavailable')
+ })
+
const PAID = { kind: NodeKind.EventsNode, event: 'paid' }
const ACTION = { kind: NodeKind.ActionsNode, id: 1 }
it.each([
diff --git a/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.ts b/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.ts
index 781816553755..6c03cb8b242c 100644
--- a/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.ts
+++ b/products/product_analytics/frontend/insights/dataChecks/insightDataChecksLogic.ts
@@ -32,6 +32,7 @@ import type {
import {
isActionsNode,
isEventsNode,
+ isFunnelsQuery,
isGroupNode,
isInsightQueryWithSeries,
isInsightVizNode,
@@ -500,7 +501,13 @@ export const insightDataChecksLogic: LogicWrapper<insightDataChecksLogicType> =
return null
}
const source = query.source
- if (!isInsightQueryWithSeries(source) || !source.series.length || !source.series.every(readsEvents)) {
+ // A funnel with one step runs no query, and the server rejects it.
+ const minSeries = isFunnelsQuery(source) ? 2 : 1
+ if (
+ !isInsightQueryWithSeries(source) ||
+ source.series.length < minSeries ||
+ !source.series.every(readsEvents)
+ ) {
return null
}
return { kind: NodeKind.InsightVizNode, source }