Skip to content

feat(explore): add multi-key support for has: search filter#109907

Merged
manessaraj merged 4 commits intomasterfrom
sarajmanes/browse-406-add-multi-key-support-for-has-search-filter-eg
Mar 9, 2026
Merged

feat(explore): add multi-key support for has: search filter#109907
manessaraj merged 4 commits intomasterfrom
sarajmanes/browse-406-add-multi-key-support-for-has-search-filter-eg

Conversation

@manessaraj
Copy link
Contributor

@manessaraj manessaraj commented Mar 4, 2026

Extends the has: search filter to accept a comma-separated list of attribute keys, allowing users to assert the presence of any of the multiple span attributes in a single token.

Previously, checking for multiple keys required chaining with OR:
has:query.period OR has:query.error_reason

With this change, users can write:
has:[query.period,query.error_reason]

Fixes BROWSE-406

@linear
Copy link

linear bot commented Mar 4, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 4, 2026
@manessaraj manessaraj marked this pull request as ready for review March 5, 2026 19:33
@manessaraj manessaraj requested review from a team as code owners March 5, 2026 19:33
Extends the `has:` search filter to accept a comma-separated list of
attribute keys, allowing users to assert the presence of multiple span
attributes in a single token.

Previously, checking for multiple keys required chaining with OR:
  has:query.period OR has:query.error_reason

With this change, users can write:
  has:[query.period,query.error_reason]

Fixes BROWSE-406
@manessaraj manessaraj force-pushed the sarajmanes/browse-406-add-multi-key-support-for-has-search-filter-eg branch from 92c1b9d to c37567a Compare March 5, 2026 19:34
Copy link
Contributor

@cursor cursor bot left a comment

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.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Nested comprehension incorrectly unwraps SearchKey NamedTuples to strings
    • Corrected return type annotations from list[list[SearchKey]] to list[SearchKey] and removed the incorrect double-nested comprehension that was unwrapping SearchKey objects into strings.

Create PR

Or push these changes by commenting:

@cursor push 696a15f77b
Preview (696a15f77b)
diff --git a/src/sentry/api/event_search.py b/src/sentry/api/event_search.py
--- a/src/sentry/api/event_search.py
+++ b/src/sentry/api/event_search.py
@@ -1813,7 +1813,7 @@
             str,  # ']'
             Node,  # terminating lookahead
         ],
-    ) -> list[list[SearchKey]]:
+    ) -> list[SearchKey]:
         return process_list(children[1], children[2])
 
     def visit_has_in_filter(
@@ -1824,11 +1824,11 @@
             Node,  # has: lookahead
             SearchKey,  # SearchKey('has')
             Node,  # :
-            list[list[SearchKey]],
+            list[SearchKey],
         ],
     ) -> ParenExpression:
         (negation, _, _, _, search_key_lst) = children
-        search_keys: list[SearchKey] = [sk for sublist in search_key_lst for sk in sublist]
+        search_keys: list[SearchKey] = search_key_lst
 
         # if it matched search value instead, it's not a valid key
         if any(isinstance(search_key, SearchValue) for search_key in search_keys):
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@getsentry getsentry deleted a comment from sentry bot Mar 6, 2026
@getsentry getsentry deleted a comment from sentry bot Mar 6, 2026
@getsentry getsentry deleted a comment from cursor bot Mar 6, 2026
Copy link
Member

@wmak wmak left a comment

Choose a reason for hiding this comment

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

🧑‍🍳 Looks great!

@manessaraj manessaraj merged commit 26e3bef into master Mar 9, 2026
76 checks passed
@manessaraj manessaraj deleted the sarajmanes/browse-406-add-multi-key-support-for-has-search-filter-eg branch March 9, 2026 19:15
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