Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sentry/api/helpers/group_index/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sentry.apidocs.response_types import ValidationErrorResponse
from sentry.deletions.defaults.group import GROUP_CHUNK_SIZE
from sentry.deletions.tasks.groups import delete_groups_for_project
from sentry.exceptions import InvalidSearchQuery

Check failure on line 21 in src/sentry/api/helpers/group_index/delete.py

View check run for this annotation

@sentry/warden / warden: sentry-backend-bugs

Malformed exception handling makes group-index helpers unimportable

The changed bulk-search handlers contain syntax errors: `delete.py` leaves the `search_fn(` call unclosed before its `except`, and `update.py` has an unclosed `Response(` before `except` plus a misplaced closing parenthesis. Since `group_index/__init__.py` imports both modules, importing the helper package fails, preventing endpoints that depend on it from loading. In the delete handler, the new combined exception branch also has no return, and the following `except ValidationError` is unreachable; after fixing the syntax, caught errors would still fall through without a valid response.
Comment thread
sentry-warden[bot] marked this conversation as resolved.
from sentry.models.group import Group, GroupStatus
from sentry.models.groupinbox import GroupInbox
from sentry.models.project import Project
Expand Down Expand Up @@ -183,10 +184,13 @@
{
"limit": BULK_MUTATION_LIMIT,
"paginator_options": {"max_limit": BULK_MUTATION_LIMIT},
}
)
except (ValidationError, InvalidSearchQuery) as exc:
# InvalidSearchQuery can be raised while building the Snuba query

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sentry get rid of this comment

# (e.g. `issue:` with a value that isn't a valid short ID), after
# parsing has already succeeded. It's a client error, not a 500.
except ValidationError as exc:
return Response({"detail": str(exc)}, status=400)

Check failure on line 193 in src/sentry/api/helpers/group_index/delete.py

View check run for this annotation

@sentry/warden / warden: sentry-backend-bugs

Malformed exception handling makes the group-index helper package unimportable

In `delete.py`, the `search_fn(` call is not closed before the `except`, and the first `except` suite contains only comments. The module therefore cannot be parsed. `sentry.api.helpers.group_index.__init__` imports `.delete`, so endpoints importing this package fail before handling requests—not merely when an invalid search query is submitted. Close the call and make the combined handler return a response, removing the duplicate handler: ```python cursor_result, _ = search_fn( { "limit": BULK_MUTATION_LIMIT, "paginator_options": {"max_limit": BULK_MUTATION_LIMIT}, } ) except (ValidationError, InvalidSearchQuery) as exc: return Response({"detail": str(exc)}, status=400) ```

group_list = list(cursor_result)

Expand Down
5 changes: 5 additions & 0 deletions src/sentry/api/helpers/group_index/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from sentry.api.serializers import serialize
from sentry.api.serializers.models.actor import ActorSerializer, ActorSerializerResponse
from sentry.api.serializers.models.groupactionlogentry import get_serialized_activity_items
from sentry.exceptions import InvalidSearchQuery

Check failure on line 26 in src/sentry/api/helpers/group_index/update.py

View check run for this annotation

@sentry/warden / warden: sentry-backend-bugs

Unclosed Response call makes the group-index update module unimportable

In `update_groups_with_search_fn`, the `Response(` opened in the `except ValidationError` branch is not closed before the next `except`. The later `)` after the `InvalidSearchQuery` response is orphaned. This makes `update.py` fail to parse, preventing endpoints that import it from loading. Close the first `Response` before the next `except` and remove the orphaned parenthesis.
from sentry.hybridcloud.rpc import coerce_id_from
from sentry.integrations.tasks.kick_off_status_syncs import kick_off_status_syncs
from sentry.issues.action_log import (
Expand Down Expand Up @@ -329,9 +330,13 @@
)
except ValidationError:
logger.exception("Error getting group ids and group list") # Track the error in Sentry
return Response(
{"detail": "Invalid query. Error getting group ids and group list"}, status=400
except InvalidSearchQuery as exc:
# Raised while building the Snuba query (e.g. `issue:` with an
# invalid short ID). This is a client error; don't report it.
return Response({"detail": str(exc)}, status=400)
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
)

Check failure on line 339 in src/sentry/api/helpers/group_index/update.py

View check run for this annotation

@sentry/warden / warden: sentry-backend-bugs

[83F-KDX] Unclosed Response call makes the group-index update module unimportable (additional location)

In `update_groups_with_search_fn`, the `Response(` opened in the `except ValidationError` branch is not closed before the next `except`. The later `)` after the `InvalidSearchQuery` response is orphaned. This makes `update.py` fail to parse, preventing endpoints that import it from loading. Close the first `Response` before the next `except` and remove the orphaned parenthesis.

group_list = list(cursor_result)

Expand Down
Loading