Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signals): deliver inbox report notifications without a resolvable reviewer (#68970)

Vojta Bartoš5c61f188c848
diff --git a/products/signals/backend/slack_inbox_notifications.py b/products/signals/backend/slack_inbox_notifications.py
index 28e13545277d..3801d598ca8b 100644
--- a/products/signals/backend/slack_inbox_notifications.py
+++ b/products/signals/backend/slack_inbox_notifications.py
@@ -5,7 +5,9 @@ Mirrors the inbox Reports tab's actionability gate: a report notifies only if it
enforced upstream — and has at least one suggested reviewer that resolves to a destination.
Each reviewer is routed to one channel: their own configured channel if set (filtered by their
min-priority), otherwise the team-default channel. Reviewers sharing a channel get a single post
-mentioning only the reviewers routed there. A report with no resolvable reviewer sends nothing.
+mentioning only the reviewers routed there. When no suggested reviewer resolves, the report is
+still delivered to the team-default channel (if one is configured) with no mentions, so a team is
+notified even when none of its members are linked to a resolvable GitHub identity.
All sends are best-effort.
"""
@@ -608,24 +610,31 @@ def _build_reviewer_routes(
team_integration: Integration | None,
team_channel: str | None,
) -> list[_ChannelRoute]:
- """Route each resolvable suggested reviewer to a single destination channel.
-
- Own channel (filtered by the reviewer's min-priority) if set, else the team default,
- else nowhere. A reviewer filtered out of their own channel does not fall back to the
- team channel — that was their choice. Reviewers sharing a destination are grouped so
- each channel is posted to once, mentioning only its own reviewers. A report whose
- reviewers don't resolve to a channel sends nothing.
+ """Route resolvable suggested reviewers to a destination channel, mentioning them there.
+
+ Own channel (filtered by the reviewer's min-priority) if set, else the team default. A reviewer
+ filtered out of their own channel does not fall back to the team channel — that was their choice.
+ Reviewers sharing a destination are grouped so each channel is posted to once, mentioning only
+ its own reviewers. When no suggested reviewer resolves, the report is still delivered to the
+ team-default channel (if configured) with no mentions, so a team is notified even when none of
+ its members are linked to a resolvable GitHub identity.
"""
reviewer_user_ids = _resolve_suggested_reviewer_user_ids(report)
- if not reviewer_user_ids:
- return []
-
reviewer_users = {user.id: user for user in User.objects.filter(id__in=reviewer_user_ids)}
own_configs = _own_channel_configs_by_user(report.team_id, reviewer_user_ids)
# Keyed by (integration_id, channel_id) so a reviewer's own channel and the team
# default collapse into one post when they resolve to the same Slack channel.
routes: dict[tuple[int, str], _ChannelRoute] = {}
+
+ def _route_for(integration: Integration, channel: str, *, is_team_channel: bool) -> _ChannelRoute:
+ key = (integration.id, _channel_id_from_target(channel))
+ route = routes.get(key)
+ if route is None:
+ route = _ChannelRoute(integration, channel, is_team_channel=is_team_channel)
+ routes[key] = route
+ return route
+
for user_id in sorted(reviewer_user_ids):
user = reviewer_users.get(user_id)
if user is None:
@@ -647,12 +656,14 @@ def _build_reviewer_routes(
if integration is None or not channel:
continue
- key = (integration.id, _channel_id_from_target(channel))
- route = routes.get(key)
- if route is None:
- route = _ChannelRoute(integration, channel, is_team_channel=is_team_channel)
- routes[key] = route
- route.users.append(user)
+ _route_for(integration, channel, is_team_channel=is_team_channel).users.append(user)
+
+ # No suggested reviewer resolved to a PostHog user: deliver to the team-default channel (if
+ # configured) so the team is still notified, without @-mentions — the message omits the
+ # suggested-reviewers section when there is nobody to tag. Per-user own channels are reviewer
+ # notifications, so they are not used here.
+ if not reviewer_user_ids and team_integration is not None and team_channel:
+ _route_for(team_integration, team_channel, is_team_channel=True)
return list(routes.values())
@@ -703,11 +714,11 @@ def dispatch_inbox_item_notifications(
team_channel=team_channel,
)
if not routes:
- # No reviewer resolved to a destination: no suggested reviewers linked to a user, none met
- # their min-priority, or there's no own/team channel to fall back to. This is the most
- # common reason an actionable report sends nothing — log the inputs so it's diagnosable.
+ # No channel to deliver to: no reviewer resolved to a destination and no notification channel
+ # is configured for the team (no per-user own channel and no team default). Log the inputs so
+ # it's diagnosable.
logger.info(
- "dispatch_inbox_item_notifications: no reviewer routes resolved, skipping",
+ "dispatch_inbox_item_notifications: no notification channel configured, skipping",
extra={
"report_id": report_id,
"team_id": team_id,
diff --git a/products/signals/backend/test/test_slack_inbox_notifications.py b/products/signals/backend/test/test_slack_inbox_notifications.py
index 77daf5bab79b..b08cb71bda75 100644
--- a/products/signals/backend/test/test_slack_inbox_notifications.py
+++ b/products/signals/backend/test/test_slack_inbox_notifications.py
@@ -450,7 +450,7 @@ def test_dispatch_posts_to_team_channel_without_per_user_config(org_and_team):
@pytest.mark.django_db
-def test_dispatch_posts_nothing_without_suggested_reviewers(org_and_team):
+def test_dispatch_falls_back_to_team_channel_without_suggested_reviewers(org_and_team):
org, team = org_and_team
creator = _make_reviewer_user(org, "[email protected]", "creator-bot")
_make_slack_integration(team, creator)
@@ -462,7 +462,33 @@ def test_dispatch_posts_nothing_without_suggested_reviewers(org_and_team):
slack_cls.return_value.client = fake_client
sent = dispatch_inbox_item_notifications(str(report.id), team.id)
- # No suggested reviewer → nothing sent, even with a team channel configured (no fallback).
+ # No suggested reviewer, but a channel is configured → still delivered, with no reviewers section.
+ assert sent == 1
+ assert fake_client.chat_postMessage.call_count == 1
+ assert fake_client.chat_postMessage.call_args.kwargs["channel"] == "CTEAM"
+ assert "Suggested reviewers" not in json.dumps(fake_client.chat_postMessage.call_args.kwargs["blocks"])
+
+
+def test_dispatch_does_not_use_own_channel_as_fallback_without_reviewers(org_and_team):
+ # A per-user own channel is a reviewer notification, not a team catch-all. With no team default
+ # channel and no resolvable reviewer, the report is not delivered to the user's own channel.
+ org, team = org_and_team
+ user = User.objects.create(email="[email protected]")
+ OrganizationMembership.objects.create(user=user, organization=org)
+ integration = _make_slack_integration(team, user)
+ SignalUserAutonomyConfig.objects.create(
+ user=user,
+ slack_notification_integration=integration,
+ slack_notification_channel="CMINE|#my-signals",
+ )
+ report = _make_ready_report(team, priority=AutonomyPriority.P2, suggested_logins=["ghost-not-in-org"])
+
+ fake_client = MagicMock()
+ with patch("products.signals.backend.slack_inbox_notifications.SlackIntegration") as slack_cls:
+ slack_cls.return_value.client = fake_client
+ sent = dispatch_inbox_item_notifications(str(report.id), team.id)
+
assert sent == 0
assert fake_client.chat_postMessage.call_count == 0