Skip to content

Conversation

@cathteng
Copy link
Member

We started handling fallthroughType correctly in dual writing here #106633

But we need a migration to fix the previously migrated email actions

@cathteng cathteng requested review from a team as code owners January 23, 2026 18:54
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 23, 2026
@cathteng cathteng marked this pull request as draft January 23, 2026 18:59
@cathteng cathteng marked this pull request as ready for review January 23, 2026 19:09
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0106_fix_email_action_fallthrough_type.py

for 0106_fix_email_action_fallthrough_type in workflow_engine

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

workflow_action.data = translated["data"]
workflow_action.config = translated["config"]
workflow_action.integration_id = translated["integration_id"]
workflow_action.save()
Copy link
Contributor

Choose a reason for hiding this comment

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

Translation failure causes misaligned workflow action updates

Medium Severity

When translate_email_action raises ValueError for any rule action, that action is skipped and the loop continues. This causes translated_actions to have fewer items than rule_email_actions, but subsequent translated actions shift to fill the gap. The migration then applies translated_actions[i] to workflow_email_actions[i] by position, causing misalignment. If the 2nd of 3 rule actions fails translation, the 3rd rule action's data gets incorrectly applied to the 2nd workflow action, while the 3rd workflow action is left unmodified.

Fix in Cursor Fix in Web

# target_identifier is only set for Member/Team, not IssueOwners
if target_type_str in ("Member", "Team"):
target_identifier = rule_action.get("targetIdentifier")
config["target_identifier"] = str(target_identifier) if target_identifier else None
Copy link
Contributor

Choose a reason for hiding this comment

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

Migration produces schema-violating config for Member/Team actions

Medium Severity

For Member/Team email actions where targetIdentifier is missing or falsy in the Rule, the migration sets config["target_identifier"] = None. However, the EmailActionHandler.config_schema requires target_identifier to be a string (not null) when target_type is USER or TEAM. Since migrations use apps.get_model(), the pre_save schema validation signal is bypassed, allowing invalid data to be saved. When someone later edits the action through normal code paths, schema validation fails with a ValidationError.

Fix in Cursor Fix in Web

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