Skip to content

feat(aci): Use search parser for Detector and Workflow index queries #94645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kcons
Copy link
Member

@kcons kcons commented Jun 30, 2025

Replace tokenization with the full parser, and derive filters from the resulting filters.

Fixes ACI-361.

@kcons kcons requested a review from malwilley June 30, 2025 19:48
@kcons kcons requested a review from a team as a code owner June 30, 2025 19:48
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 30, 2025
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@malwilley malwilley left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!

assert isinstance(filter, SearchFilter)
match filter:
case SearchFilter(key=SearchKey("name"), operator=("=" | "IN" | "!=")):
queryset = apply_filter(queryset, filter, "name")
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if this works for wildcards like name:*issue*? The parser does look for those, just not sure if what it outputs will work with the __iexact filtering in apply_filter or not

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't targeting full syntax support, just more support with a parser that makes it easier for us to extend support as needed. That said, it's not too hard, so I added wildcard.

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 93.84615% with 4 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../sentry/workflow_engine/endpoints/utils/filters.py 82.60% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #94645    +/-   ##
========================================
  Coverage   85.24%   85.25%            
========================================
  Files       10416    10420     +4     
  Lines      602665   602948   +283     
  Branches    23451    23451            
========================================
+ Hits       513759   514032   +273     
- Misses      88154    88164    +10     
  Partials      752      752            

Copy link

@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.

Bug: Type Checking Vulnerability in Production

The assert isinstance(filter, SearchFilter) statement is used for runtime type checking, but as assertions can be disabled in production, this could lead to runtime errors or unexpected behavior if the search query parser returns non-SearchFilter objects.

src/sentry/workflow_engine/endpoints/organization_workflow_index.py#L111-L112

for filter in parse_workflow_query(raw_query):
assert isinstance(filter, SearchFilter)

src/sentry/workflow_engine/endpoints/organization_detector_index.py#L130-L131

for filter in parse_detector_query(raw_query):
assert isinstance(filter, SearchFilter)

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

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