ref(crons): Reorganize incident creation / issue occurrence logic#3
ref(crons): Reorganize incident creation / issue occurrence logic#3ShashankFC wants to merge 1 commit into
Conversation
…0528) Since we'll be doing more with issue occurrences split out the concept of incidents into it's own logic module, as well as incident_occurrence into it's own module Part of GH-80527
|
@cubic-dev-ai review this pull request |
@ShashankFC I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/sentry/monitors/logic/incident_occurrence.py">
<violation number="1" location="src/sentry/monitors/logic/incident_occurrence.py:132">
P3: Typo in docstring: "humam readible" should be "human readable".</violation>
<violation number="2" location="src/sentry/monitors/logic/incident_occurrence.py:168">
P1: Bug: Returns the original `monitor_environment.monitor.config` instead of the locally modified `config` copy. The `schedule_type` display transformation on line 167 is silently discarded.</violation>
</file>
<file name="src/sentry/monitors/logic/incidents.py">
<violation number="1" location="src/sentry/monitors/logic/incidents.py:52">
P1: Missing check that enough check-ins exist to meet the failure threshold. If fewer check-ins exist than `failure_issue_threshold` (e.g., a newly created monitor), an incident will be created prematurely because the code only verifies that none of the returned check-ins are OK, not that there are *enough* failures to meet the threshold.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| "id": str(monitor_environment.monitor.guid), | ||
| "slug": str(monitor_environment.monitor.slug), | ||
| "name": monitor_environment.monitor.name, | ||
| "config": monitor_environment.monitor.config, |
There was a problem hiding this comment.
P1: Bug: Returns the original monitor_environment.monitor.config instead of the locally modified config copy. The schedule_type display transformation on line 167 is silently discarded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/monitors/logic/incident_occurrence.py, line 168:
<comment>Bug: Returns the original `monitor_environment.monitor.config` instead of the locally modified `config` copy. The `schedule_type` display transformation on line 167 is silently discarded.</comment>
<file context>
@@ -0,0 +1,171 @@
+ "id": str(monitor_environment.monitor.guid),
+ "slug": str(monitor_environment.monitor.slug),
+ "name": monitor_environment.monitor.name,
+ "config": monitor_environment.monitor.config,
+ "status": monitor_environment.get_status_display(),
+ "type": monitor_environment.monitor.get_type_display(),
</file context>
|
|
||
| # If we have any successful check-ins within the threshold of | ||
| # commits we have NOT reached an incident state | ||
| if any([checkin["status"] == CheckInStatus.OK for checkin in previous_checkins]): |
There was a problem hiding this comment.
P1: Missing check that enough check-ins exist to meet the failure threshold. If fewer check-ins exist than failure_issue_threshold (e.g., a newly created monitor), an incident will be created prematurely because the code only verifies that none of the returned check-ins are OK, not that there are enough failures to meet the threshold.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/monitors/logic/incidents.py, line 52:
<comment>Missing check that enough check-ins exist to meet the failure threshold. If fewer check-ins exist than `failure_issue_threshold` (e.g., a newly created monitor), an incident will be created prematurely because the code only verifies that none of the returned check-ins are OK, not that there are *enough* failures to meet the threshold.</comment>
<file context>
@@ -0,0 +1,104 @@
+
+ # If we have any successful check-ins within the threshold of
+ # commits we have NOT reached an incident state
+ if any([checkin["status"] == CheckInStatus.OK for checkin in previous_checkins]):
+ return False
+
</file context>
|
|
||
| def get_failure_reason(failed_checkins: Sequence[SimpleCheckIn]): | ||
| """ | ||
| Builds a humam readible string from a list of failed check-ins. |
There was a problem hiding this comment.
P3: Typo in docstring: "humam readible" should be "human readable".
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/monitors/logic/incident_occurrence.py, line 132:
<comment>Typo in docstring: "humam readible" should be "human readable".</comment>
<file context>
@@ -0,0 +1,171 @@
+
+def get_failure_reason(failed_checkins: Sequence[SimpleCheckIn]):
+ """
+ Builds a humam readible string from a list of failed check-ins.
+
+ "3 missed check-ins detected"
</file context>
Test 8
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.
Replicated from ai-code-review-evaluation/sentry-coderabbit#8