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(error-tracking): return a 400 for too many search tokens (#109030)

posthog[bot]d743b6c36aae
diff --git a/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py b/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py
index 0a702aaacc36..4e7574549e57 100644
--- a/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py
+++ b/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py
@@ -3,7 +3,7 @@ from collections.abc import Callable
from typing import Any, cast
from uuid import UUID
-from django.core.exceptions import ValidationError
+from rest_framework.exceptions import ValidationError
from posthog.schema import (
ErrorTrackingIssueFilter,
diff --git a/products/error_tracking/backend/hogql_queries/test/test_error_tracking_query_runner.py b/products/error_tracking/backend/hogql_queries/test/test_error_tracking_query_runner.py
index 18c894899630..2ba319cc5dd3 100644
--- a/products/error_tracking/backend/hogql_queries/test/test_error_tracking_query_runner.py
+++ b/products/error_tracking/backend/hogql_queries/test/test_error_tracking_query_runner.py
@@ -1579,10 +1579,16 @@ class TestErrorTrackingQueryRunner(ClickhouseTestMixin, NonAtomicBaseTestKeepIde
# bins are left-closed [start, end), so events on an exact bin boundary land in the next bin
self.assertEqual(first_aggregations["volumeRange"], [55, 60, 5, 0])
- @parameterized.expand(["issueId", "personId"])
- def test_rejects_malformed_uuid_params(self, field):
+ @parameterized.expand(
+ [
+ ("malformed_issue_id", "issueId", "test-distinct-id"),
+ ("malformed_person_id", "personId", "test-distinct-id"),
+ ("too_many_search_tokens", "searchQuery", " ".join(["token"] * 101)),
+ ]
+ )
+ def test_rejects_invalid_params(self, _name, field, value):
with self.assertRaises(ValidationError):
- self._calculate(**{field: "test-distinct-id"})
+ self._calculate(**{field: value})
def test_canonicalizes_uuid_params(self):
runner = ErrorTrackingQueryRunner(