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(query): treat clickhouse incorrect_element_of_set as a user error (#117468)

posthog[bot]21a6c06e5939
diff --git a/posthog/errors.py b/posthog/errors.py
index c43e14e117d3..236d9d8dc70a 100644
--- a/posthog/errors.py
+++ b/posthog/errors.py
@@ -513,7 +513,11 @@ CLICKHOUSE_ERROR_CODE_LOOKUP: dict[int, ErrorCodeMeta] = {
),
122: ErrorCodeMeta("INCOMPATIBLE_COLUMNS", user_safe=True), # column types don't match expected schema
123: ErrorCodeMeta("UNKNOWN_TYPE_OF_AST_NODE"),
- 124: ErrorCodeMeta("INCORRECT_ELEMENT_OF_SET"),
+ 124: ErrorCodeMeta(
+ "INCORRECT_ELEMENT_OF_SET",
+ user_safe="An element of an IN set is invalid. Make sure each tuple in the IN list has the same number "
+ "of elements as the left side, and that each element is a constant.",
+ ),
125: ErrorCodeMeta(
"INCORRECT_RESULT_OF_SCALAR_SUBQUERY",
user_safe="A scalar subquery returned more than one row, or an empty result that cannot be nullable. "
diff --git a/posthog/test/test_errors.py b/posthog/test/test_errors.py
index dbdb5de61ba1..3d5481134ccc 100644
--- a/posthog/test/test_errors.py
+++ b/posthog/test/test_errors.py
@@ -65,6 +65,12 @@ class TestWrapClickhouseQueryError:
"UNSUPPORTED_JOIN_KEYS",
"Unsupported JOIN keys. Check the expressions and types used to join your tables.",
),
+ (
+ 124,
+ "INCORRECT_ELEMENT_OF_SET",
+ "An element of an IN set is invalid. Make sure each tuple in the IN list has the same number "
+ "of elements as the left side, and that each element is a constant.",
+ ),
(
125,
"INCORRECT_RESULT_OF_SCALAR_SUBQUERY",