forked from ai-code-review-evaluation/sentry-greptile
-
Notifications
You must be signed in to change notification settings - Fork 4
Add hook for producing occurrences from the stateful detector #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hussam789
wants to merge
1
commit into
workflow-engine-stateful-detector-before
Choose a base branch
from
workflow-engine-stateful-detector-after
base: workflow-engine-stateful-detector-before
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+249
−151
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
New build_occurrence_and_event_data hook and PriorityLevel cast — verify enum alignment and subclasses
The new
build_occurrence_and_event_dataabstract method plus the updatedevaluate/evaluate_group_key_valueflow give a clear extension point for detectors to constructIssueOccurrence+ event payloads, which is a nice separation of concerns.Two follow-ups are worth tightening:
Here
new_statusis aDetectorPriorityLevel. This relies on the underlying integer values lining up withPriorityLevelso the cast is valid. If they ever diverge, you’ll getValueErroror incorrect priorities on the occurrences.It might be safer long term to provide an explicit converter (e.g. a helper that maps
DetectorPriorityLevel→PriorityLevel) rather than relying on raw IntEnum value equality.Adding
build_occurrence_and_event_dataas an abstract method means every concreteStatefulDetectorHandlersubclass must now implement it; otherwise those classes remain abstract and can’t be instantiated. Tests coverMockDetectorStateHandler, but it’s worth checking for any production subclasses that might now be missing an implementation.You can scan for subclasses to verify they all override this hook:
Also applies to: 226-245, 285-308
🏁 Script executed:
Length of output: 177
I'll correct the script and verify the concerns from the review comment.
Length of output: 0
🏁 Script executed:
Length of output: 490
🏁 Script executed:
Length of output: 10376
🏁 Script executed:
Length of output: 6948
🏁 Script executed:
Length of output: 2241
I need to check the full implementation of
MetricAlertDetectorHandlerand verify thePriorityLevelenum values.🏁 Script executed:
Length of output: 1073
🏁 Script executed:
Length of output: 2316
🏁 Script executed:
Length of output: 865
Enum cast will fail on DetectorPriorityLevel.OK; MetricAlertDetectorHandler missing required implementation
The
PriorityLevel(new_status)cast at line 300 has a real alignment problem.PriorityLevelenum only defines LOW (25), MEDIUM (50), and HIGH (75), butDetectorPriorityLevel.OKhas value 0. Whennew_status == DetectorPriorityLevel.OK, the cast will raiseValueError.Additionally,
MetricAlertDetectorHandlerinsrc/sentry/incidents/grouptype.py:11is a concrete subclass but only containspass—it never implements the required abstract methodbuild_occurrence_and_event_data. Although marked with a TODO comment suggesting future work, it's currently referenced asdetector_handlerinMetricAlertFireand cannot be instantiated.Recommended fixes:
DetectorPriorityLevel→PriorityLevelthat handlesOK(e.g., map it to a safe default or raise a clearer error).build_occurrence_and_event_datainMetricAlertDetectorHandleror make it explicitly abstract (or stub it withNotImplementedError).🤖 Prompt for AI Agents