fix(alerts): Stronger typing around human_desc#117883
Open
kcons wants to merge 3 commits into
Open
Conversation
saponifi3d
approved these changes
Jun 16, 2026
| priority = obj.data.get("priority") | ||
| priority: str | None = obj.data.get("priority") | ||
| type_value = ActionService.get_value(obj.type) | ||
| assert type_value is not None, f"Unknown ActionService for type {obj.type}" |
Contributor
There was a problem hiding this comment.
Bug: The assert in WorkflowEngineActionSerializer will cause a crash when serializing workflow actions with types like GITHUB or JIRA, as they are not supported by ActionService.
Severity: HIGH
Suggested Fix
Instead of asserting, the serializer should gracefully handle unsupported action types. This could involve filtering them out from the serialized output or logging a warning and skipping the problematic action, which would prevent the API endpoint from crashing.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/incidents/endpoints/serializers/workflow_engine_action.py#L58
Potential issue: The `WorkflowEngineActionSerializer` uses an `assert` to validate that
the `obj.type` of a `workflow_engine.Action` is a valid `ActionService`. However, the
`Action.Type` enum allows for types like `GITHUB`, `JIRA`, `WEBHOOK`, and `PLUGIN`,
which are not defined in `ActionService`. When `ActionService.get_value()` is called
with one of these unsupported types, it returns `None`. This triggers the `assert
type_value is not None` statement, raising an `AssertionError` and crashing the API
endpoint responsible for serializing metric alert rules. This will prevent users with
alert rules configured with these action types from viewing or managing them.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
There were previously exceptions due to type issues that should've been easy to catch statically here, so it's worth being explicit with the typing and simplifying where we can to avoid such issues recurring.
I aimed to minimize behavior changes, but found 4 pre-existing bugs in the process that addition type refinements and simplifications made visible to tools, so fixed those too.