Skip to content

fix(workflows): Correctly convert boolean filter values for Snuba queries#115532

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/workflow-snuba-bool-conversion
Draft

fix(workflows): Correctly convert boolean filter values for Snuba queries#115532
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/workflow-snuba-bool-conversion

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 13, 2026

This PR addresses a QueryExecutionError originating from ClickHouse when evaluating workflow alert conditions that include filters like error.handled = false.

Root Cause:
The convert_filter_to_snuba_condition function in sentry/workflow_engine/handlers/condition/event_frequency_query_handlers.py was passing the string literal 'false' directly to Snuba for the error.handled attribute. This attribute maps to the exception_stacks.mechanism_handled column in ClickHouse, which is of type UInt8. ClickHouse cannot implicitly convert the string 'false' to a UInt8, leading to a type conversion error.

Additionally, a subtle bug was identified in the handling of error.unhandled. The expression not condition["value"] (where condition["value"] could be the string 'false') would incorrectly evaluate to False because any non-empty string is truthy in Python. This meant that a filter for error.unhandled = false was being translated to handled = False instead of the semantically correct handled = True.

Fix:
The logic for both error.handled and error.unhandled within convert_filter_to_snuba_condition has been updated and consolidated. It now correctly parses the string value ('true' or 'false') from the condition into a Python boolean (True or False) before constructing the Snuba query. This ensures that ClickHouse receives a compatible boolean/integer type for the UInt8 column, resolving the type conversion error and correctly interpreting the error.unhandled filter.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-5PE8

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants