fix(attribute-values): Properly support boolean attributes#8000
Conversation
- The endpoint allows attribute values but currently breaks because it makes some assumptions where the value would be a string. This fixes those cases so that we can use this endpoint for booleans
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5928272. Configure here.
Clean up the boolean-attribute handling so this endpoint properly supports booleans: - Replace the duplicated string/bool existence-check branches with an _ATTRIBUTE_TYPE_TO_COLUMN map, so supporting more types later is a single map entry. - Serialize boolean values as lowercase "true"/"false" instead of Python's "True"/"False". This matches how booleans are stringified across the EAP filter API, so returned values round-trip as filter inputs. Using bool(value) also guards against ClickHouse returning 0/1 ints. - Add tests for substring-match-on-boolean and unsupported-type rejection paths. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/_s-xOkXMoHkYblOZj1F_Om7TSAa3RNtVZSRIKERI1NY
The Sentry review bot flagged f.has() on the attributes_bool Map column as a potential bug. Verified it actually works in ClickHouse (the existence check correctly excludes items missing the key), so the finding is a false positive — but mapContains is the correct, conventional function for Map key existence used everywhere else in the codebase, and HashBucketFunctionTransformer rewrites it for the bucketed string/float maps too. Switch to it for consistency and robustness. Add test_boolean_existence_check with a bool attribute present on only some items, giving real coverage of the existence filter (the existing test seeds sentry.is_segment on every item, so it never exercised it). Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/6-4z37eRB8njhxT5P2w26JW2W9u_jJGuQGxZhX0AMgM
|
Re: the Sentry review-bot findings about To prove it I added That said, I still switched the existence check from |

Summary
The
TraceItemAttributeValuesRPC enumerates the distinct values an attributetakes (used to populate filter-value autocomplete). It previously assumed every
attribute was a string, so querying a boolean attribute broke. This makes
the endpoint properly support booleans.
Changes
attributes_bool,not
attributes_string. A small_ATTRIBUTE_TYPE_TO_COLUMNmap drives thehas(...)check by attribute type; unsupported types raise a clearBadSnubaRPCRequestException. Adding more types later is a one-line map entry.value_substring_matchcompiles to aSQL
LIKE, which only makes sense for strings — it now raises on non-stringkeys instead of producing a broken query.
valuesfield isrepeated string, so booleans must be serialized as strings. They're returnedas lowercase
"true"/"false"— matching how booleans are stringified acrossthe EAP filter API — so the returned values round-trip as filter inputs.
Serializing via
bool(value)also guards against ClickHouse returning0/1.Tests
test_boolean_case— enumerating a boolean attribute returns["true", "false"]with the expected counts.test_substring_match_on_boolean_rejected— substring match on a boolean isrejected.
test_unsupported_attribute_type_rejected— non-string/bool types arerejected.