Skip to content

fix(workflow_engine): Record fire history for eligible workflows - #132541

Open
shashjar wants to merge 2 commits into
shashjar/feat/iswf-3705-inbox-frequencyfrom
shashjar/fix/iswf-3705-eligible-fire-history
Open

shashjar wants to merge 2 commits into
shashjar/feat/iswf-3705-inbox-frequencyfrom
shashjar/fix/iswf-3705-eligible-fire-history

Conversation

@shashjar

@shashjar shashjar commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Record a fire-history row for each workflow whose conditions and configured action frequency passed. Previously, when two workflows shared an action, one could receive a history row even though its conditions failed or it was throttled.

Immediate and delayed processing now share the same history and dispatch logic. If both workflows qualify, each gets a history row and the shared action is dispatched once with the selected workflow’s notification UUID. The history writer checks the supplied workflow IDs against the event’s organization.

Stacked on #131093, which supplies the eligible actions and their workflow attribution.

Refs ISWF-3705. Tech spec

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

No findings on the latest commit.

@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

ISWF-3705

@shashjar
shashjar force-pushed the shashjar/fix/iswf-3705-eligible-fire-history branch from 417639d to 09f6bd3 Compare November 25, 2026 16:58
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 25, 2026
@shashjar
shashjar marked this pull request as ready for review November 25, 2026 18:51
@shashjar
shashjar requested a review from a team as a code owner November 25, 2026 18:51
@shashjar
shashjar requested a review from a team November 25, 2026 18:51

@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.

It'd be great if we could DRY the code up a bit more with a helper method for triggering these actions; that way we could encapsulate all the different aspects of triggering an action within workflow engine.

enqueue_workflows(batch_client, delayed_items)

actions, action_to_workflow_id = filter_recently_fired_workflow_actions(
actions, action_to_workflow_id, eligible_workflow_ids = filter_recently_fired_workflow_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.

🤔 should we move all of this code into a shared method so we can reduce the code replication between process_workflows and processing the delayed workflows?

Something like:

# processors/action.py
def trigger_actions(action_groups, event_data, *, is_delayed, start_timestamp) -> TriggeredActions:
    actions, action_to_workflow_id, eligible_workflow_ids = filter_recently_fired_workflow_actions(action_groups, event_data)
    if not actions:
        return TriggeredActions.empty()
        
    histories = create_workflow_fire_histories(
        eligible_workflow_ids,
        event_data,
        is_delayed=is_delayed,
        start_timestamp=start_timestamp,
    )
    
    workflow_notification_mapping = {h.workflow_id: str(h.notification_uuid) for h in histories}
    fire_actions(actions, event_data, workflow_notification_mapping, action_to_workflow_id)
    return TriggeredActions(actions, action_to_workflow_id, histories)

(probably means changes elsewhere if you want to go with this method as is).

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, added trigger_actions in src/sentry/workflow_engine/processors/action.py

is_delayed: bool = False,
start_timestamp: datetime | None = None,
*,
eligible_workflow_ids: Collection[WorkflowId],

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: this method signature feels a little awkward that there's a required keyword-only argument after optional positional arguments. maybe this should just be keywords so the argument order doesn't matter?

@shashjar
shashjar marked this pull request as draft December 3, 2026 03:32
@shashjar
shashjar force-pushed the shashjar/fix/iswf-3705-eligible-fire-history branch from 9e8050e to f405b33 Compare December 3, 2026 03:37
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
scraps Ignored Ignored Preview Dec 3, 2026 3:48am UTC

Request Review

@shashjar
shashjar changed the base branch from master to shashjar/feat/iswf-3705-inbox-frequency December 3, 2026 03:37
Share history creation and dispatch across immediate and delayed evaluations.
Record every eligible workflow for a shared action and dispatch once with its
selected workflow’s notification UUID.

Refs ISWF-3705
Materialize the scoped workflow IDs for metrics and history writes.
Pin the eligible history IDs when one workflow sharing an action is throttled.

Refs ISWF-3705
@shashjar
shashjar force-pushed the shashjar/feat/iswf-3705-inbox-frequency branch from ccdf440 to 89b03ef Compare December 3, 2026 03:47
@shashjar
shashjar force-pushed the shashjar/fix/iswf-3705-eligible-fire-history branch from f405b33 to 7b89c6d Compare December 3, 2026 03:47
@shashjar
shashjar marked this pull request as ready for review December 3, 2026 03:54
@shashjar
shashjar requested a review from saponifi3d December 3, 2026 03:55

This branch was successfully deployed

1 active (outdated) deployment
Preview — 9b2f1c84 Deployed Nov 30, 2026 by vercel[bot]
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