Skip to content

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Jan 27, 2026

When users select multiple release versions via checkboxes in the Issues page search bar, the frontend generates a query like release.version:[1.2.3,1.2.4] with an IN operator. Previously this raised "Invalid operation 'IN' for semantic version filter" because the semver filter converters didn't handle the IN operator.

This change adds support for the IN operator with list values in:

  • _semver_filter_converter and semver_filter_converter: iterate through each version in the list, query matching releases for each, and combine results
  • _semver_build_filter_converter and semver_build_filter_converter: pass the list directly to filter_by_semver_build
  • filter_by_semver_build: accept a sequence of builds and use build_number__in / build_code__in for the query

Fixes #76286

When users select multiple release versions via checkboxes in the Issues
page search bar, the frontend generates a query like
`release.version:[1.2.3,1.2.4]` with an IN operator. Previously this
raised "Invalid operation 'IN' for semantic version filter" because the
semver filter converters didn't handle the IN operator.

This change adds support for the IN operator with list values in:
- `_semver_filter_converter` and `semver_filter_converter`: iterate
  through each version in the list, query matching releases for each,
  and combine results
- `_semver_build_filter_converter` and `semver_build_filter_converter`:
  pass the list directly to `filter_by_semver_build`
- `filter_by_semver_build`: accept a sequence of builds and use
  `build_number__in` / `build_code__in` for the query

Fixes GH-76286
Co-Authored-By: Claude <noreply@anthropic.com>
@dcramer dcramer requested review from a team as code owners January 27, 2026 19:48
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 27, 2026
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 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

try:
django_op = constants.OPERATOR_TO_DJANGO[operator]
except KeyError:
raise InvalidSearchQuery("Invalid operation 'IN' for semantic version filter.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Misleading error message hardcodes 'IN' for non-IN operators

Low Severity

The error message at this location hardcodes "Invalid operation 'IN'" but now that IN is supported (added to OPERATOR_TO_DJANGO), this KeyError can only be triggered by other invalid operators like "NOT IN", "LIKE", etc. The parse_semver function was correctly updated to use an f-string with the actual operator (f"Invalid operation '{operator}'") but this fix wasn't applied to semver_build_filter_converter or _semver_build_filter_converter. This results in confusing error messages when users use unsupported operators.

Additional Locations (1)

Fix in Cursor Fix in Web

if not versions:
versions = [SEMVER_EMPTY_RELEASE]

return ["release", "IN", versions]
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing validation check for array parameter size limit

Medium Severity

The new IN operator handling in _semver_filter_converter is missing the validate_snuba_array_parameter(versions) check that exists in the parallel implementation semver_filter_converter in filter_aliases.py. When multiple versions are queried, each can return up to MAX_SEARCH_RELEASES results which get extended into the versions list. Without validation, this could pass an excessively large array to Snuba, potentially causing query failures or performance issues. The validation was added in filter_aliases.py at line 223 but omitted here.

Fix in Cursor Fix in Web

"NOT IN": "IN",
}
OPERATOR_TO_DJANGO = {">=": "gte", "<=": "lte", ">": "gt", "<": "lt", "=": "exact"}
OPERATOR_TO_DJANGO = {">=": "gte", "<=": "lte", ">": "gt", "<": "lt", "=": "exact", "IN": "in"}
Copy link
Contributor

Choose a reason for hiding this comment

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

IN operator with non-list value causes crash instead of error

Low Severity

Adding "IN": "in" to OPERATOR_TO_DJANGO creates a regression for edge cases where operator == "IN" but the value is a single string rather than a list. Previously, this would raise a clean InvalidSearchQuery via the KeyError handler. Now, "IN" passes validation but the downstream code in filter_by_semver_build attempts qs.filter(build_number__in=int(single_value)), which causes a TypeError because Django's __in lookup requires an iterable, not an integer. While this edge case may not be reachable through normal UI usage, the type annotations explicitly allow this combination.

Additional Locations (1)

Fix in Cursor Fix in Web

@scttcper scttcper requested a review from a team January 27, 2026 19:58
@dcramer
Copy link
Member Author

dcramer commented Jan 27, 2026

To be clear I'm not sure what a "correct" solution is here, so will need perspective from someone who has context here. Is this the general approach we would take to fix the bug? Ignoring the line by line details?

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

2 participants