Skip to content

feat(issue-workflow): Add notification platform support for deploy notifs#120398

Open
leeandher wants to merge 1 commit into
leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-3from
leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-4
Open

feat(issue-workflow): Add notification platform support for deploy notifs#120398
leeandher wants to merge 1 commit into
leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-3from
leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-4

Conversation

@leeandher

Copy link
Copy Markdown
Member

Adds a new route specifically for deploy notifications. They are not like any other activity notification because the activity does not matter for them, they need a deploy/release (not group).

The template already exists, this just adds a helper to build the data, and a strategy to notify committers + people who want to know about releases.

Ideally this wouldn't be tied to activity at all, but that was the trigger system for these notificiations before and we aren't changing that here


Stack created with GitHub Stacks CLIGive Feedback 💬

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

ISWF-3085

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 22, 2026
@leeandher
leeandher force-pushed the leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-4 branch from 1c85775 to 623fdc4 Compare July 22, 2026 21:47
@leeandher
leeandher force-pushed the leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-3 branch from ecbadc2 to b489875 Compare July 22, 2026 21:47
@sentry

sentry Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 451 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@leeandher
leeandher requested a review from a team July 22, 2026 21:51
@leeandher
leeandher marked this pull request as ready for review July 22, 2026 21:51
@leeandher
leeandher requested review from a team as code owners July 22, 2026 21:51
Comment thread src/sentry/notifications/platform/templates/deploy.py
DeployReleaseCommit(
author_name=author_name,
date=commit.date_added.isoformat() if commit.date_added else "",
sha=commit.key[:7],

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.

Incorrect commit SHA shortening

Low Severity

Commit SHAs are truncated with commit.key[:7] instead of commit.short_id. short_id only shortens 40-character hashes and otherwise returns the full key, which matches legacy deploy emails. Non-SHA keys longer than 7 characters will be truncated incorrectly in the new notifications.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 623fdc4. Configure here.

@leeandher
leeandher force-pushed the leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-3 branch from b489875 to d91d1dd Compare July 22, 2026 21:56
@leeandher
leeandher force-pushed the leanderrodrigues/iswf-3085-create-separate-route-for-activity-to-render-via-4 branch from 623fdc4 to 4963aef Compare July 22, 2026 21:56

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

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

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 4963aef. Configure here.

author_name=author_name,
date=commit.date_added.isoformat() if commit.date_added else "",
sha=commit.key[:7],
message=commit.message or "",

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.

Full commit message in notifications

Medium Severity

Commit bodies are stored as the full commit.message. Legacy deploy emails use commit.title (first line only). Multi-line commit messages will inflate Slack/email deploy notifications with long bodies that the previous experience intentionally omitted.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4963aef. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems legit

Comment on lines +43 to +44
if not deploy or not release:
return

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.

Bug: If get_deploy() or get_release() returns None, deploy notifications are silently dropped without falling back to the legacy system.
Severity: MEDIUM

Suggested Fix

Modify _send_deploy_activity_notification to handle cases where get_deploy() or get_release() return None. The function should explicitly call the legacy notification function, _send_legacy_activity_notification, as a fallback to ensure notifications are not silently dropped.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/tasks/activity.py#L43-L44

Potential issue: For organizations with access to the new notification platform, if
`get_deploy()` or `get_release()` returns `None` (e.g., due to a `DoesNotExist`
exception), the `_send_deploy_activity_notification` function will return prematurely.
This new logic prevents a fallback to the legacy notification system, which was the
behavior prior to this change for `DEPLOY` activity. Consequently, deploy notifications
in these scenarios will be silently dropped instead of being sent through the old
system.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread src/sentry/tasks/activity.py
ParagraphSection,
PlainTextBlock,
)
from sentry.notifications.utils import get_environment_for_deploy, get_group_counts_by_project

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.

Deploy notification crashes if environment is deleted

get_environment_for_deploy does Environment.objects.get(id=deploy.environment_id) without handling DoesNotExist. If the environment is deleted after the deploy is created, the send_activity_notifications task crashes. Fix: wrap the .get() in try/except Environment.DoesNotExist inside get_environment_for_deploy so it falls back to 'Default Environment'.

Evidence
  • build_deploy_release_data calls get_environment_for_deploy(deploy) without guarding for Environment.DoesNotExist.
  • get_environment_for_deploy in sentry/notifications/utils/__init__.py does Environment.objects.get(id=deploy.environment_id) directly with no try/except.
  • This is called from _send_deploy_activity_notification inside send_activity_notifications, which is a Celery task; an unhandled DoesNotExist will crash and retry the task.
  • Deploy.environment_id is a raw integer field with no FK constraint, so the environment record can be deleted independently.
Also found at 1 additional location
  • src/sentry/notifications/platform/templates/deploy.py:272

Identified by Warden sentry-backend-bugs · R3E-LPN

@ceorourke ceorourke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

broken record but does this need tests too?


def build_deploy_release_data(deploy: Deploy, release: Release) -> DeployReleaseDataResult:
organization = release.organization
projects = set(release.projects.all())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need to limit this to some number?

author_name=author_name,
date=commit.date_added.isoformat() if commit.date_added else "",
sha=commit.key[:7],
message=commit.message or "",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems legit

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