-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
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 |
There was a problem hiding this 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
sentry/src/sentry/workflow_engine/endpoints/organization_workflow_index.py
Lines 111 to 112 in 78f391f
for filter in parse_workflow_query(raw_query): | |
assert isinstance(filter, SearchFilter) |
src/sentry/workflow_engine/endpoints/organization_detector_index.py#L130-L131
sentry/src/sentry/workflow_engine/endpoints/organization_detector_index.py
Lines 130 to 131 in 78f391f
for filter in parse_detector_query(raw_query): | |
assert isinstance(filter, SearchFilter) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Replace tokenization with the full parser, and derive filters from the resulting filters.
Fixes ACI-361.