: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): classify query validation errors as broken queries (#130877)
posthog[bot]400b6ebdbc5e
diff --git a/products/signals/backend/anomaly_scores/tick.py b/products/signals/backend/anomaly_scores/tick.pyindex 6993df5a9826..76ca54df1509 100644--- a/products/signals/backend/anomaly_scores/tick.py+++ b/products/signals/backend/anomaly_scores/tick.py@@ -18,6 +18,7 @@ from django.core.cache import cachefrom django.utils import timezoneimport structlog+from rest_framework.exceptions import ValidationErrorfrom temporalio import activity, workflowfrom temporalio.common import RetryPolicyfrom temporalio.exceptions import ActivityError, ApplicationError@@ -320,6 +321,9 @@ def failure_status(error: Exception) -> str | None:# Only the exposed invalid-query error, such as an unknown table. ResolutionError is internal to the engine.if isinstance(error, QueryError):return STATUS_BROKEN_QUERY+ # A query runner raises this for a saved query that its validation rules reject, so a later tick cannot pass.+ if isinstance(error, ValidationError):+ return STATUS_BROKEN_QUERYreturn Nonediff --git a/products/signals/backend/test/test_anomaly_scoring_tick.py b/products/signals/backend/test/test_anomaly_scoring_tick.pyindex f1ed9e7b3620..802f43befda7 100644--- a/products/signals/backend/test/test_anomaly_scoring_tick.py+++ b/products/signals/backend/test/test_anomaly_scoring_tick.py@@ -17,6 +17,7 @@ from django.test import SimpleTestCase, override_settingsimport numpy as npfrom parameterized import parameterized+from rest_framework.exceptions import ValidationErrorfrom temporalio import activityfrom temporalio.client import WorkflowFailureErrorfrom temporalio.testing import WorkflowEnvironment@@ -741,6 +742,7 @@ class TestRunInsight(SimpleTestCase):("timeout", ClickHouseQueryTimeOut(), "too_expensive"),("access_denied", TableAccessDeniedError("no access"), "access_denied"),("unknown_table", QueryError("Unknown table `deleted_table`."), "broken_query"),+ ("invalid_query", ValidationError("Not supported.", code="unsupported_settings"), "broken_query"),("unsupported", UnsupportedInsightError("not trends"), "unsupported"),])