Skip to content

Commit 4833749

Browse files
authored
fix(llm-detector): Add better platform parsing (#104475)
some platforms aren't accepted as event platform so we were seeing `other` for `python-flask` projects for example. now, we will pass along the best match rather than `other` fixes https://linear.app/getsentry/issue/ID-1130/some-issues-still-have-other-as-platform
1 parent 65ca3b4 commit 4833749

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ pnpm-lock.yaml @getsentry/owners-js-de
578578
/src/sentry/tasks/merge.py @getsentry/issue-detection-backend
579579
/src/sentry/tasks/unmerge.py @getsentry/issue-detection-backend
580580
/src/sentry/tasks/weekly_escalating_forecast.py @getsentry/issue-detection-backend
581-
/src/sentry/tasks/llm_issue_detection.py @getsentry/issue-detection-backend
581+
/src/sentry/tasks/llm_issue_detection/ @getsentry/issue-detection-backend
582582
/static/app/components/events/contexts/ @getsentry/issue-workflow
583583
/static/app/components/events/eventTags/ @getsentry/issue-workflow
584584
/static/app/components/events/highlights/ @getsentry/issue-workflow

src/sentry/tasks/llm_issue_detection/detection.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pydantic import BaseModel
1111

1212
from sentry import features, options
13+
from sentry.constants import VALID_PLATFORMS
1314
from sentry.issues.grouptype import LLMDetectedExperimentalGroupType
1415
from sentry.issues.issue_occurrence import IssueEvidence, IssueOccurrence
1516
from sentry.issues.producer import PayloadType, produce_occurrence_to_kafka
@@ -72,6 +73,30 @@ def __init__(
7273
self.error_message = error_message
7374

7475

76+
def get_base_platform(platform: str | None) -> str | None:
77+
"""
78+
Extract the base platform from a platform identifier.
79+
80+
Examples:
81+
python-flask -> python
82+
python-django -> python
83+
javascript-react -> javascript
84+
python -> python
85+
"""
86+
if not platform:
87+
return None
88+
89+
if platform in VALID_PLATFORMS:
90+
return platform
91+
92+
base_platform = platform.split("-")[0]
93+
94+
if base_platform in VALID_PLATFORMS:
95+
return base_platform
96+
97+
return None
98+
99+
75100
def create_issue_occurrence_from_detection(
76101
detected_issue: DetectedIssue,
77102
trace: EvidenceTraceData,
@@ -119,10 +144,12 @@ def create_issue_occurrence_from_detection(
119144
level="warning",
120145
)
121146

147+
platform = get_base_platform(project.platform) or "other"
148+
122149
event_data = {
123150
"event_id": event_id,
124151
"project_id": project_id,
125-
"platform": project.platform or "other",
152+
"platform": platform,
126153
"received": detection_time.isoformat(),
127154
"timestamp": detection_time.isoformat(),
128155
"transaction": transaction_name,

0 commit comments

Comments
 (0)