ref(crons): Reorganize incident creation / issue occurrence logic#3
Open
adamsaimi wants to merge 1 commit intomonitor-incident-refactor-beforefrom
Open
ref(crons): Reorganize incident creation / issue occurrence logic#3adamsaimi wants to merge 1 commit intomonitor-incident-refactor-beforefrom
adamsaimi wants to merge 1 commit intomonitor-incident-refactor-beforefrom
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
adamsaimi
commented
Oct 25, 2025
| # - The monitor and env are not muted | ||
| if not monitor_env.monitor.is_muted and not monitor_env.is_muted and incident: | ||
| checkins = MonitorCheckIn.objects.filter(id__in=[c["id"] for c in previous_checkins]) | ||
| for checkin in checkins: |
Owner
Author
There was a problem hiding this comment.
[Bug] Duplicate Incident Creation
- Problem: When
failure_issue_threshold > 1,create_incident_occurrenceis incorrectly called multiple times, resulting infailure_issue_thresholdKafka messages for a single incident and unnecessary load. - Fix: Modify the logic to ensure
create_incident_occurrenceis called only once per incident creation, using the most recent failed check-in and allprevious_checkinsfor context.
# Only create one occurrence for the incident, using the most recent failed_checkin
# and the full list of previous_checkins for context.
create_incident_occurrence(
previous_checkins,
failed_checkin, # Use the single failed_checkin that triggered this call
incident,
received=received,
)```
adamsaimi
commented
Oct 25, 2025
| "id": str(monitor_environment.monitor.guid), | ||
| "slug": str(monitor_environment.monitor.slug), | ||
| "name": monitor_environment.monitor.name, | ||
| "config": monitor_environment.monitor.config, |
Owner
Author
There was a problem hiding this comment.
[Security] Potential Information Leakage
- Problem: The
monitor_environment.monitor.configis directly included in the event context, which could expose sensitive information like API keys or internal paths. - Fix: Explicitly filter or sanitize the
configdictionary to include only non-sensitive, relevant fields before adding it to the event context.
# ... other fields ...
\"config\": {k: v for k, v in monitor_environment.monitor.config.items() if k not in [\"sensitive_key_1\", \"sensitive_key_2\"]}, # Example filtering
# ... other fields ...
}```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test 8