Repository navigation
ref(notifications): Use explicit origins for notification rendering - #126529
Merged
Merged
Conversation
Contributor
Sentry Snapshot Testing
|
Contributor
There was a problem hiding this comment.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 067bde9. Configure here.
Construct workflow-backed notification origins explicitly so a null workflow environment overrides any environment stored on the linked legacy rule.
Keep serializing the proxy ID in the legacy rules field while NotificationOrigin replaces synthetic Rule objects in rendering. The workflow-only payload transition remains isolated to the follow-up integration PR.
hobzcalvin
approved these changes
Oct 6, 2026
Comment on lines
+27
to
+41
| embedded_workflow_id = first_action.get("workflow_id") | ||
| embedded_legacy_rule_id = first_action.get("legacy_rule_id") | ||
|
|
||
| if embedded_workflow_id is not None: | ||
| embedded_workflow_id = int(embedded_workflow_id) | ||
| if embedded_legacy_rule_id is not None: | ||
| embedded_legacy_rule_id = int(embedded_legacy_rule_id) | ||
|
|
||
| if embedded_legacy_rule_id is not None: | ||
| legacy_rule_id = embedded_legacy_rule_id | ||
| elif embedded_workflow_id is not None: | ||
| legacy_rule_id = None | ||
| else: | ||
| legacy_rule_id = rule.id | ||
|
|
Contributor
There was a problem hiding this comment.
nit: the logic here seems more drawn out than it needs to be, though I don't have a specific rewrite in mind.
Share legacy identity parsing between persisted rules and serialized payloads, document transitional origin IDs, and avoid unrelated naming and query-shape changes.
3 tasks done
kcons
added a commit
that referenced
this pull request
Oct 15, 2026
First of two steps to reduce `SerializableRuleProxy` to a serializable `NotificationOrigin`. Its only consumer is `to_notification_origin()` (Slack/Discord/MS Teams issue renderers). **Changes** - Remove the `from_legacy_data` fallback in `to_notification_origin()`. It only covered `notify_target_async` payloads serialized before #126529 (merged 10-06) put `workflow_id`/`legacy_rule_id` at the top level. Those tasks should have drained by now. - Remove `NotificationOrigin.from_legacy_data` from prod code; its parsing now lives only in the `create_notification_origin` test helper. - `NotificationOrigin.__post_init__` logs `notifications.origin.missing_identity` (warning, with stack) when both `workflow_id` and `legacy_rule_id` are `None`. `identifier`/`link_id` depend on at least one being set, so this points at the producer instead of only failing at the later assert. - Make `id`, `data`, and `project_id` optional. Nothing reads them anymore, but producers still populate them because workers on the previous release require them. - Replace `model_config = ConfigDict(frozen=True)` with `class Config: frozen = True`. On pydantic 1.10, `model_config` is treated as an ordinary field: the model wasn't actually frozen, and every serialized payload carried `"model_config": {"frozen": true}`. Parsing stays compatible in both directions: extra keys are ignored, and old workers fall back to the field default. **Follow-up (after this deploys)** Stop populating and delete `id`/`data`/`project_id`, then remove `from_action_context` and the `build_rule_data_from_action` call in `issue_notification_data_factory`. **Testing** - Every test file using `create_notification_origin`/`create_notification_action_context`, plus `tests/sentry/notifications/platform/` and `tests/sentry/notifications/notification_action/`: 959 passed. 3 order-dependent failures under xdist (`msteams/test_action_state_change.py`, `slack/notifications/test_issue_alert.py`) pass when those files run on their own, on master and on this branch. - After the logging change: `tests/sentry/notifications/`, `tests/sentry/digests/`, and the Slack/MS Teams message builder tests pass, apart from Redis Cluster tests that need a cluster not running locally and one xdist-only flake (`test_get_context_users_affected`) that passes on its own. - `prek run` + pre-push mypy on changed files: pass - Tests that relied on the legacy fallback now pass explicit identities. The two legacy-deserialization tests are replaced with tests for frozen behavior and parsing a previous-release payload. New test covers the missing-identity log. <!-- junior-request-attribution:start --> via @kcons. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0BT0DUS6SX%3A1792088281.199639 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AD0BT0DUS6SX%3A1792088281.199639) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0BT0DUS6SX%3A1792088281.199639/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Kyle Consalus <6990351+kcons@users.noreply.github.com>
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.

Introduce NotificationOrigin to represent the workflow (or for a time longer, rule) that caused a notification
so we don't have to keep using Rule.
NotificationOrigin is much more constrained and specific, allowing us to replace some of the subtler Rule hacks with explicit choices.
Fixes ISWF-3560.