feat(workflows) Add a workflow engine implementation of OrganizationIncidentIndexEndpoint.get#110956
feat(workflows) Add a workflow engine implementation of OrganizationIncidentIndexEndpoint.get#110956
Conversation
5e75882 to
6269622
Compare
| try: | ||
| teams_query, unassigned = parse_team_params(request, organization, teams) | ||
| except InvalidParams as err: | ||
| return Response(str(err), status=status.HTTP_400_BAD_REQUEST) |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, to fix this class of problem, avoid returning raw exception objects or their string representations directly to clients. Instead, log or capture detailed error information server-side, and send a generic or tightly-controlled error response to the client. For validation-like errors, return a simple, predefined message or an extracted, sanitized portion of the error, rather than str(err).
Here, we should adjust the except InvalidParams as err: block around lines 241–244. The best fix that preserves existing behavior (a 400 response indicating invalid parameters) while preventing potential information exposure is:
- Stop returning
str(err)directly. - Replace it with a generic but still informative message, such as
"Invalid team parameters"or a fixed phrase indicating invalid request parameters. - Alternatively, if the project has a standard error response format (e.g.,
{"detail": "..."}), we would follow that, but we haven’t been shown that code, so we should just change the body string.
Concretely, in src/sentry/incidents/endpoints/organization_incident_index.py:
- Locate the
except InvalidParams as err:block around line 243. - Replace
return Response(str(err), status=status.HTTP_400_BAD_REQUEST)with aResponsethat uses a fixed, non-sensitive message, e.g.return Response("Invalid team parameters", status=status.HTTP_400_BAD_REQUEST).
This requires no new imports or helper methods and does not change the status code or high-level control flow, only the message content.
| @@ -240,8 +240,8 @@ | ||
| if teams: | ||
| try: | ||
| teams_query, unassigned = parse_team_params(request, organization, teams) | ||
| except InvalidParams as err: | ||
| return Response(str(err), status=status.HTTP_400_BAD_REQUEST) | ||
| except InvalidParams: | ||
| return Response("Invalid team parameters", status=status.HTTP_400_BAD_REQUEST) | ||
|
|
||
| team_filter_query = Q( | ||
| group__detectorgroup__detector__owner_team_id__in=teams_query.values_list( |
9c5e52e to
b50a5a4
Compare
Backend Test FailuresFailures on
|
9aa5b7d to
ceea059
Compare
Backend Test FailuresFailures on
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hardcoded string instead of existing constant for data source type
- Replaced the hardcoded string 'snuba_query_subscription' with the imported constant DATA_SOURCE_SNUBA_QUERY_SUBSCRIPTION from sentry.incidents.utils.types to ensure consistency.
Or push these changes by commenting:
@cursor push 613346b3ff
Preview (613346b3ff)
diff --git a/src/sentry/incidents/endpoints/organization_incident_index.py b/src/sentry/incidents/endpoints/organization_incident_index.py
--- a/src/sentry/incidents/endpoints/organization_incident_index.py
+++ b/src/sentry/incidents/endpoints/organization_incident_index.py
@@ -27,6 +27,7 @@
from sentry.incidents.grouptype import MetricIssue
from sentry.incidents.models.alert_rule import AlertRuleActivity, AlertRuleActivityType
from sentry.incidents.models.incident import Incident, IncidentStatus
+from sentry.incidents.utils.types import DATA_SOURCE_SNUBA_QUERY_SUBSCRIPTION
from sentry.models.environment import Environment
from sentry.models.groupopenperiod import GroupOpenPeriod
from sentry.models.organization import Organization
@@ -291,7 +292,7 @@
source_id_as_int=Cast("data_source__source_id", output_field=BigIntegerField())
)
.filter(
- data_source__type="snuba_query_subscription",
+ data_source__type=DATA_SOURCE_SNUBA_QUERY_SUBSCRIPTION,
source_id_as_int__in=subscription_qs.values("id"),
)
.values("detector_id")This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
…ncidentIndexEndpoint.get
f45b477 to
8178a62
Compare


This one is a notable perf risk.
This is part of the project described in src/sentry/workflow_engine/docs/legacy_backport.md.