Commit 3edac08
fix(attribute-values): Properly support boolean attributes (#8000)
## Summary
The `TraceItemAttributeValues` RPC enumerates the distinct values an
attribute
takes (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
- **Existence check on the right column.** Booleans live in
`attributes_bool`,
not `attributes_string`. A small `_ATTRIBUTE_TYPE_TO_COLUMN` map drives
the
`has(...)` check by attribute type; unsupported types raise a clear
`BadSnubaRPCRequestException`. Adding more types later is a one-line map
entry.
- **Substring match guarded to strings.** `value_substring_match`
compiles to a
SQL `LIKE`, which only makes sense for strings — it now raises on
non-string
keys instead of producing a broken query.
- **Lowercase boolean values.** The response proto's `values` field is
`repeated string`, so booleans must be serialized as strings. They're
returned
as lowercase `"true"`/`"false"` — matching how booleans are stringified
across
the EAP filter API — so the returned values round-trip as filter inputs.
Serializing via `bool(value)` also guards against ClickHouse returning
`0`/`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 is
rejected.
- `test_unsupported_attribute_type_rejected` — non-string/bool types are
rejected.
---------
Co-authored-by: Pierre Massat <pierre.massat@sentry.io>1 parent 8e4cfa3 commit 3edac08
2 files changed
Lines changed: 75 additions & 2 deletions
File tree
- snuba/web/rpc/v1
- tests/web/rpc/v1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
54 | 71 | | |
55 | 72 | | |
56 | | - | |
| 73 | + | |
57 | 74 | | |
58 | 75 | | |
59 | 76 | | |
| |||
63 | 80 | | |
64 | 81 | | |
65 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
66 | 87 | | |
67 | 88 | | |
68 | 89 | | |
| |||
200 | 221 | | |
201 | 222 | | |
202 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
203 | 228 | | |
204 | 229 | | |
205 | | - | |
| 230 | + | |
| 231 | + | |
206 | 232 | | |
207 | 233 | | |
208 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
0 commit comments