types: Move sentry.search.events.filter from mypy ignore to stronglist#113191
types: Move sentry.search.events.filter from mypy ignore to stronglist#113191
Conversation
Backend Test FailuresFailures on
|
| # We explicitly use `raw_value` here to avoid converting wildcards to shell values | ||
| version: str = search_filter.value.raw_value | ||
| raw_version = search_filter.value.raw_value | ||
| assert isinstance(raw_version, str) |
There was a problem hiding this comment.
Assertion crashes with 500 instead of returning 400 for unsupported semver IN-list syntax
The new assert isinstance(raw_version, str) on line 337 will raise AssertionError (500 error) when a user queries with list syntax like release.version:[1.0.0, 2.0.0]. Before this change, the list would pass through to parse_semver() which properly raises InvalidSearchQuery("Invalid operation 'IN' for semantic version filter.") (400 error). The assertion is used for type narrowing but blocks reaching the user-friendly error handler.
Verification
Traced the code path: 1) text_in_filter grammar rule matches release.version:[...] syntax and creates SearchFilter with list raw_value and operator='IN'. 2) Filter routes to _semver_filter_converter. 3) Line 337 assertion fails on list type. 4) Previously, parse_semver (line 481-483) would catch 'IN' operator and raise InvalidSearchQuery. SearchValue.raw_value type is str | float | datetime | Sequence[float] | Sequence[str].
Suggested fix: Replace assertion with explicit type check that raises InvalidSearchQuery for non-string values, maintaining the user-friendly error message.
| assert isinstance(raw_version, str) | |
| if not isinstance(raw_version, str): | |
| raise InvalidSearchQuery( | |
| "Invalid operation 'IN' for semantic version filter." | |
| ) |
Identified by Warden sentry-backend-bugs · EN3-URR
Fixes ENG-6456.