Skip to content

feat(workflow_engine): Support group-less action invocation - #131090

Merged
shashjar merged 16 commits into
masterfrom
shashjar/feat/iswf-3705-group-less-actions
Nov 30, 2026
Merged

shashjar merged 16 commits into
masterfrom
shashjar/feat/iswf-3705-group-less-actions

Conversation

@shashjar

@shashjar shashjar commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs https://linear.app/getsentry/issue/ISWF-3705/support-group-less-action-invocation-and-inbox-frequency-semantics.

Allow an action to run without an issue group or project when its required detector belongs to the event’s organization. Handlers declare reusable event validators for checks before dispatch and invocation validators for checks that need a resolved detector. Issue notifications require a group and a project-scoped detector. Seer requires a group.

https://app.notion.com/p/sentry/Investigation-Events-Workflow-Engine-40c8b10e4b5d80d18c4ed6c802d55d64

@linear-code

linear-code Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

ISWF-3705

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 13, 2026
@shashjar
shashjar added this pull request to stack #131096 November 13, 2026 18:30
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch 3 times, most recently from c194918 to ea1da2e Compare November 20, 2026 00:13
@shashjar
shashjar removed this pull request from stack #131096 November 20, 2026 00:15
@shashjar
shashjar changed the base branch from shashjar/ref/iswf-3705-explicit-action-detector to master November 20, 2026 00:15
@shashjar
shashjar added this pull request to stack #131948 November 20, 2026 00:15
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch from ea1da2e to e42eca5 Compare November 20, 2026 00:16
@shashjar
shashjar marked this pull request as ready for review November 21, 2026 17:41
@shashjar
shashjar requested review from a team as code owners November 21, 2026 17:42
@shashjar
shashjar requested review from a team and removed request for a team November 21, 2026 17:42
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch from 3ba2795 to 00a80c4 Compare November 23, 2026 16:44
@shashjar
shashjar requested a review from a team November 23, 2026 17:39
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch from 00a80c4 to c8e9b88 Compare November 24, 2026 19:19
@shashjar
shashjar requested a review from saponifi3d November 24, 2026 20:44


class IntegrationActionHandler(ActionHandler, ABC):
class IssueNotificationActionHandler(ActionHandler):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 i think this breaks liskov substitution principle; (the L in SOLID) -- this base class couldn't replace the parent class, because it forces the the input types.

Is there something we could add to the ActionHandler to enforce for us? that way instead of using inheritance to do these definitions, everything is clearly outlines.

That could look something like:

class ActionHandler(Generic[T]):
   def validate_data(data: T) -> None:

It could also look something like:

class ActionHandler:
    on_validation: []

where on_validation is a list of methods to call to validate the data.


i personally prefer the latter; because it allows for more options per handler. here's kinda the way the latter might play out.

So instead of: class EmailActionHandler(IssueNotificationActionHandler): we can say;

class EmailActionHandler(ActionHandler):
   on_validation: [ActionHandler.ISSUE_REQUIRED.validate],

^ that way all the action handlers have the same shape / basic structures.


Claude should also be able to help give a few other ideas if you want to dive into this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, refactored for the action handlers to contain validators to run

@shashjar
shashjar marked this pull request as draft November 25, 2026 15:37
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch from a46f2cc to 0d88a80 Compare November 25, 2026 16:51
Keep real detector and organization context while requiring handlers to opt in to group-less execution.

Refs ISWF-3705
Restore the processor organization lookup while retaining cached ownership validation for actions.
Enabling evaluation emission for unannotated preprod, processing-errors, and legacy uptime
detectors is separate work.

Refs ISWF-3705
Remove the unused annotation fast path and keep task tracking in the PR description.

Refs ISWF-3705
Replace the group-less capability flag with handler-owned validation before dispatch and execution. Notification handlers require a group and detector project; Seer requires only a group. Keep organization ownership validation in the action model.

Refs ISWF-3705
Reuse the invocation test for group-less execution and mock Seer at its execution boundary.

Refs ISWF-3705
Name the shared base for its issue-group and project-scoped detector requirements.

Refs ISWF-3705
Declare event checks before dispatch and detector checks after resolution. Seer shares the group check with issue actions while keeping its own detector requirements.
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-group-less-actions branch from 0d88a80 to b365838 Compare November 25, 2026 16:58
@shashjar
shashjar marked this pull request as ready for review November 25, 2026 17:52
@shashjar
shashjar requested a review from saponifi3d November 25, 2026 17:52

@saponifi3d saponifi3d left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, the comments are things that i think we might want to improve if we have the time to do so.

The most critical thing to check before merging is that actions.exclude will use the django cache for actions and not issue an additional query to the db.

Comment on lines +22 to +23
event_validators = (require_issue_group,)
invocation_validators = (require_project_scoped_detector,)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! i really like how declarative this is now 🎉

Comment on lines +14 to +15
require_issue_group,
require_project_scoped_detector,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might be nice to add these to a class / enum so they're namespaced; ActionValidators.ISSUE_REQUIRED for example could namespace the validate method for requiring an issue. In the future, if we have other things around the action + an issue, we could add them to that class.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new src/sentry/workflow_engine/handlers/action_validators.py for now (open to thoughts if there's a better location) and made the imports namespaced on module (i.e. action_validators.require_issue_group and action_validators.require_project_scoped_detector)


CACHE_TTL = 60 * 10

def get_organization_id(self) -> int | None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already a method: _get_detector_organization in processors/detector.py that does this -- could we reuse that instead of introducing another? or replace the other with this one -- i do kinda like it being attached to the detector directly, and i think that's where most folks would look first.

The other has a nice win that it checks the detector cache first, if it doesn't find it then it loads the org from the cache too.

"event_id": event_data.event_id,
},
)
return actions.exclude(id__in=unsupported_ids) if unsupported_ids else actions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 does django make a second query for actions since we've already iterated them or will this use the cache'd data and then filter that? (might be worth confirming that it doesn't do another query, mostly because this layer would be called enough that it might add significant load to the db if there's an additional query).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, looks like this creates a new queryset so when a handler rejects an action another SELECT runs (but in the regular path of all actions being supported the original queryset gets reused)

i changed this so unsupported actions just get skipped while iterating the original queryset instead of calculating a new one

Comment thread src/sentry/workflow_engine/types.py Outdated
Comment on lines +242 to +249
def require_issue_group(event_data: WorkflowEventData) -> None:
if event_data.group is None:
raise UnsupportedActionEvent("This action requires an issue group")


def require_project_scoped_detector(invocation: ActionInvocation) -> None:
if invocation.detector.project_id is None:
raise UnsupportedActionEvent("This action requires a project-scoped detector")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, probably a nit, but i don't feel like these should be in types.py but i'm not sure of a better place for them to live right now, maybe handlers/action/utils.py or something like that?

we can probably also treat this comment as a nit, and then find a good place to have ActionHandler + these co-located.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new src/sentry/workflow_engine/handlers/action_validators.py for now

Validate handlers during deduplication to avoid a second query on rejection.
Count rejections by action type.

Refs ISWF-3705
A disabled action with a retired type must not block dispatch of active actions.

Refs ISWF-3705
@shashjar
shashjar merged commit 6d69548 into master Nov 30, 2026
104 checks passed
@shashjar
shashjar deleted the shashjar/feat/iswf-3705-group-less-actions branch November 30, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants