fix(insights): handle non-boolean filter values on boolean properties#58703
fix(insights): handle non-boolean filter values on boolean properties#58703sampennington wants to merge 1 commit into
Conversation
|
🎭 Playwright didn't run on this PR — your changes touch code that could affect E2E behavior, but Playwright is opt-in via label now to keep CI cost down. Add the Most PRs don't need this. Real regressions still get caught on master and fix-forward. |
Filtering a Boolean-typed property with a value that is not a valid boolean (e.g. a stray org id from a bad saved filter) produced equals(toBool(...), 'foo'), which ClickHouse rejects with CANNOT_PARSE_BOOL and fails the whole insight query. _handle_bool_values now resolves the filter value against the boolean property for every value, not just literal "true"/"false": recognized boolean representations map to a bool, anything else maps to None so the comparison matches no rows instead of crashing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8c565bc to
e538c2e
Compare
Automated code reviewReviewed the diff and surrounding Needs attention —
|
Problem
Filtering a Boolean-typed property with a value that isn't a valid boolean crashed the whole insight query with ClickHouse
CANNOT_PARSE_BOOL. Surfaced fromsystem.query_log(exception_code = 467) as part of the effort to reduce deterministic query-builder bugs (dashboard).The property-type swapper coerces a Boolean property to
toBool(...)._handle_bool_valuesonly resolved the filter value when it was literally"true"/"false"— any other value (e.g. a stray non-boolean string from a bad saved filter) was passed through as a string, producingequals(toBool(...), '<non-boolean string>'), which ClickHouse can't parse.Changes
_resolve_boolean_valuehelper: maps recognized boolean representations (true/false/yes/no/1/0/…) to a bool, and anything else toNone._handle_bool_valuesnow resolves the value against the boolean property for every value, so a non-boolean value yieldsNone— the comparison matches no rows instead of crashing. (This also means"1"/"yes"-style values now correctly resolve to a bool.)How did you test this code?
I'm an agent. Automated tests run locally:
TestBooleanPropertyComparisonWithDataexecuting the generated SQL —true/falsematch, a non-boolean value returns 0 rows.posthog/hogql/test/test_property.pysuite — 129 passed.Publish to changelog?
no
🤖 Agent context
Authored by Claude Code (Opus 4.7). Found via
system.query_loganalysis (exception_code = 467,CANNOT_PARSE_BOOL).Trade-off: the early-return fast path in
_handle_bool_values(which skipped the PropertyDefinition lookup for non-true/falsevalues) is removed, since detecting a Boolean property requires the lookup regardless of the value. This adds one indexed lookup perexact/is_notcomparison at query-build time. Batching this with the property-type swapper's existing bulk lookup is a possible follow-up.Agent-authored; requires human review.