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): coerce nullable arg in flag-exposure skill query (#68416)

posthog[bot]1fee4722eb0d
diff --git a/products/error_tracking/skills/investigating-error-issue/SKILL.md b/products/error_tracking/skills/investigating-error-issue/SKILL.md
index c88021f055a8..b995df98cdb8 100644
--- a/products/error_tracking/skills/investigating-error-issue/SKILL.md
+++ b/products/error_tracking/skills/investigating-error-issue/SKILL.md
@@ -167,14 +167,19 @@ If the user suspects an experiment or rollout, check whether affected users had
a flag enabled when the error fired.
To enumerate which flags were evaluated on affected users, parse the
-`$active_feature_flags` property — it is materialized as a JSON-encoded string in
-ClickHouse, so `arrayJoin(properties.$active_feature_flags)` directly will fail;
-`JSONExtract` is the working pattern:
+`$active_feature_flags` property — it is materialized as a `Nullable(String)`
+JSON-encoded column in ClickHouse, so `arrayJoin(properties.$active_feature_flags)`
+directly will fail. `JSONExtract` is the working pattern, but you must coerce the
+argument to a non-nullable String first: ClickHouse refuses to return a nested
+`Array(String)` from `JSONExtract` when the input is `Nullable`, and this type
+error is raised at query planning, so the `notEmpty(...)` guard in the WHERE
+clause does not prevent it. Wrap the argument in `ifNull(..., '[]')` (or
+`assumeNotNull(...)`):
```sql
posthog:execute-sql
SELECT
- arrayJoin(JSONExtract(toString(properties.$active_feature_flags), 'Array(String)')) AS flag,
+ arrayJoin(JSONExtract(ifNull(toString(properties.$active_feature_flags), '[]'), 'Array(String)')) AS flag,
count() AS occurrences,
uniq(person_id) AS users
FROM events