Skip to content

feat(explore): Support array attributes in trace item attributes endpoint - #121184

Merged
manessaraj merged 6 commits into
masterfrom
sarajmanes/feat/EXP-1130_array-attributes-endpoint
Aug 4, 2026
Merged

feat(explore): Support array attributes in trace item attributes endpoint#121184
manessaraj merged 6 commits into
masterfrom
sarajmanes/feat/EXP-1130_array-attributes-endpoint

Conversation

@manessaraj

@manessaraj manessaraj commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

Classify each attribute-names RPC result by the type Snuba returns rather than the type requested.
cooccurring-attrs v1 returns scalars for arrays, thus requested type is not same as returned type.

Arrays are in coocurring-attrs v2 and has been rolled out completely, so tests are marked with proper annotations to cover the roll out.

Refs EXP-1130

@linear-code

linear-code Bot commented Aug 4, 2026

Copy link
Copy Markdown

EXP-1130

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 4, 2026
…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
@manessaraj
manessaraj force-pushed the sarajmanes/feat/EXP-1130_array-attributes-endpoint branch from 74a7829 to b8f9fb7 Compare August 4, 2026 17:59
Comment thread src/sentry/api/endpoints/organization_trace_item_attributes.py
@manessaraj
manessaraj marked this pull request as ready for review August 4, 2026 19:11
@manessaraj
manessaraj requested review from a team as code owners August 4, 2026 19:11
Comment on lines 321 to 327
}


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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b29a8e2. Configure here.

Comment thread src/sentry/search/eap/utils.py
Comment thread src/sentry/api/endpoints/organization_trace_item_attributes.py
@manessaraj
manessaraj enabled auto-merge (squash) August 4, 2026 20:10
@manessaraj
manessaraj merged commit 7dfacfa into master Aug 4, 2026
83 of 85 checks passed
@manessaraj
manessaraj deleted the sarajmanes/feat/EXP-1130_array-attributes-endpoint branch August 4, 2026 20:28
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.

2 participants