feat(explore): Support array attributes in trace item attributes endpoint - #121184
Conversation
…oint Add `array` as a queryable attribute type in the trace-item attributes endpoint, gated behind organizations:trace-item-array-query-support. When the flag is on, custom array attributes surface as `tags[<name>,array]` so the Explore autocomplete can offer them; when off, the array pass is not run and array attributes are never returned. Refs EXP-1130
74a7829 to
b8f9fb7
Compare
| } | ||
|
|
||
|
|
||
| def _search_type_to_context_type(search_type: str) -> Literal["string", "number", "boolean"]: | ||
| def _search_type_to_context_type(search_type: str) -> ColumnType: | ||
| """Collapse an EAP search type to the coarse type used for context matching.""" | ||
| if search_type == "string": | ||
| return "string" |
There was a problem hiding this comment.
Bug: The _search_type_to_context_type function's implementation was not updated to handle the "array" type, causing it to incorrectly return "number" and breaking future context matching.
Severity: LOW
Suggested Fix
Update the _search_type_to_context_type function to handle the "array" search_type by returning "array". This will align the implementation with the updated type signature and prevent future silent failures.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/api/endpoints/organization_trace_item_attributes.py#L321-L327
Potential issue: The function `_search_type_to_context_type` maps a search type to a
context type. While its type signature was updated to include `"array"`, the
implementation was not, causing it to default to returning `"number"` for any
unrecognized type. If a Sentry-defined column is ever added with `search_type="array"`,
this function will return `"number"`. A downstream check
`_search_type_to_context_type(...) != attribute_type` will then fail when
`attribute_type` is `"array"`, causing context matching to fail silently for that
attribute. This is a latent bug that will manifest if array-typed Sentry columns are
introduced in the future.
Also affects:
src/sentry/api/endpoints/organization_trace_item_attributes.py:396~402
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b29a8e2. Configure here.
|
|
||
| POSSIBLE_ATTRIBUTE_TYPES = ["string", "number", "boolean"] | ||
| SCALAR_ATTRIBUTE_TYPES = ["string", "number", "boolean"] | ||
| POSSIBLE_ATTRIBUTE_TYPES = [*SCALAR_ATTRIBUTE_TYPES, "array"] |
There was a problem hiding this comment.
Shared type list breaks context API
Medium Severity
Expanding POSSIBLE_ATTRIBUTE_TYPES with array also widens validation on the attribute-context PUT endpoint, which imports that same list. That path still casts through TraceItemAttributeTypes, which has no array id, so get_id_for_type_name("array") returns None and persistence can fail when attributeType=array is sent.
Reviewed by Cursor Bugbot for commit b29a8e2. Configure here.


Add
arrayas a queryable attribute type in the trace-item attributes endpoint, gated behind organizations:trace-item-array-query-support. When the flag is on, custom array attributes surface astags[<name>,array]so the Explore autocomplete can offer them; when off, the array pass is not run and array attributes are never returned.Classify each attribute-names RPC result by the type Snuba returns rather than the type requested.
cooccurring-attrsv1 returns scalars for arrays, thus requested type is not same as returned type.Arrays are in
coocurring-attrsv2 and has been rolled out completely, so tests are marked with proper annotations to cover the roll out.Refs EXP-1130