Skip to content

chore(ACI): Handle prepare_component_fields in WorkflowEngineRuleSerializer#109423

Open
ceorourke wants to merge 7 commits intomasterfrom
ISWF-2136
Open

chore(ACI): Handle prepare_component_fields in WorkflowEngineRuleSerializer#109423
ceorourke wants to merge 7 commits intomasterfrom
ISWF-2136

Conversation

@ceorourke
Copy link
Member

@ceorourke ceorourke commented Feb 26, 2026

The WorkflowEngineRuleSerializer accepted the prepare_component_fields arg but didn't do anything with it - this PR fetches the component data and adds it to the serializer response. This PR is based off of how RuleSerializer handles this arg but has to be implemented in a slightly different way for workflows.

@ceorourke ceorourke requested a review from a team as a code owner February 26, 2026 00:57
@linear
Copy link

linear bot commented Feb 26, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 26, 2026
arw = AlertRuleWorkflow.objects.get(rule_id=issue_alert.id)
workflow = arw.workflow

workflow = IssueAlertMigrator(issue_alert).run()
Copy link
Member Author

Choose a reason for hiding this comment

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

create_project_rule already runs the IssueAlertMigrator here so we only need to fetch the already created workflow.

self.issue_alert.update(owner_user_id=self.user.id)
self.issue_alert.refresh_from_db()
self.assert_equal_serializers(self.issue_alert)
issue_alert = self.create_project_rule(
Copy link
Member Author

Choose a reason for hiding this comment

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

Since I removed the duplicate IssueAlertMigrator.run() call the workflow we use now wouldn't update it's owner so we have to do it here.


@responses.activate
def test_sentry_app_render_label(self) -> None:
responses.add(
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this response to resolve the assignee field from the alert rule action schema.

{
"id": "sentry.rules.actions.notify_event_sentry_app.NotifyEventSentryAppAction",
"sentryAppInstallationUuid": installation.uuid,
"settings": [
Copy link
Member Author

Choose a reason for hiding this comment

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

These correspond to the schema linked in my comment above

@ceorourke ceorourke requested a review from a team February 26, 2026 01:03
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


serialized_actions = []
for action in self._fetch_actions(workflow_dcg.condition_group):
# build up actions data
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to refactor this a bit to build up the actions data before we loop over each action to avoid N+1 calls to build up the component data

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.

1 participant