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(loops): reject blank payload condition values (#78632)

Tom Piccirello6ffb3b97e491
diff --git a/products/tasks/backend/presentation/serializers_loops.py b/products/tasks/backend/presentation/serializers_loops.py
index 7115d08eb0e8..273fb4b67afc 100644
--- a/products/tasks/backend/presentation/serializers_loops.py
+++ b/products/tasks/backend/presentation/serializers_loops.py
@@ -237,6 +237,12 @@ def _validate_payload_conditions(raw: Any) -> list[dict[str, Any]]:
raise serializers.ValidationError(
{"filters": f"Payload condition '{path}' needs `equals`: a string or a non-empty list of strings."}
)
+ # A blank value can't equal any real payload leaf, so the condition would save and then
+ # never fire — the same silent dead end as a list-index path above.
+ if any(not item.strip() for item in values):
+ raise serializers.ValidationError(
+ {"filters": f"Payload condition '{path}' has a blank `equals` value, which would never match."}
+ )
if len(values) > MAX_PAYLOAD_CONDITION_VALUES or any(len(item) > MAX_PAYLOAD_STRING_LENGTH for item in values):
raise serializers.ValidationError(
{
diff --git a/products/tasks/backend/tests/test_loops_api.py b/products/tasks/backend/tests/test_loops_api.py
index c6c03e07b7fa..f2086374cc8b 100644
--- a/products/tasks/backend/tests/test_loops_api.py
+++ b/products/tasks/backend/tests/test_loops_api.py
@@ -1077,6 +1077,9 @@ class LoopGithubTriggerValidationAPITest(LoopsAPITestCase):
("too_many_path_segments", {"payload": [{"path": ".".join("abcdefghi"), "equals": "x"}]}),
("missing_equals", {"payload": [{"path": "requested_team.slug"}]}),
("empty_equals", {"payload": [{"path": "requested_team.slug", "equals": []}]}),
+ # Also saves fine and then never fires: no payload leaf is the empty string.
+ ("blank_equals_string", {"payload": [{"path": "requested_team.slug", "equals": " "}]}),
+ ("blank_equals_among_values", {"payload": [{"path": "requested_team.slug", "equals": ["a", ""]}]}),
("non_string_equals", {"payload": [{"path": "pull_request.number", "equals": 7}]}),
("too_many_conditions", {"payload": [{"path": f"a{i}", "equals": "x"} for i in range(17)]}),
# The allowlist is how an agent discovers the vocabulary after a failed call.