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): check project access before inbox notifications (#102477)

Paul D'Ambrab95e2c36af74
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index f110367435c4..75c4b3c83f07 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -8,6 +8,12 @@ The shared PR-linking service applies this rule to task outputs and agent attach
An existing attachment retry does not reopen a report, and importing legacy assignments preserves its status.
Suppressed reports remain suppressed when another PR is attached.
+## Reviewer notifications
+
+Slack notifications for a ready report include only reviewers who have access to the report's project when delivery starts.
+The same access rule applies when a reviewer is added later.
+If no suggested reviewer has access, the ready report still goes to the configured team channel without reviewer mentions.
+
## Scout revisions
Scout edits increment the content revision count only when the title or summary changes. Notes, evidence, routing updates, and unchanged text do not spend a revision. The edit response always includes the report's running revision total.
diff --git a/products/mcp_store/backend/test/test_oauth.py b/products/mcp_store/backend/test/test_oauth.py
index 523f5803149c..f132b4437b0e 100644
--- a/products/mcp_store/backend/test/test_oauth.py
+++ b/products/mcp_store/backend/test/test_oauth.py
@@ -150,7 +150,10 @@ class TestRefreshOauthToken(SimpleTestCase):
mock_resp.json.return_value = {"access_token": "new-token", "refresh_token": "new-refresh"}
mock_resp.raise_for_status = MagicMock()
- with patch("products.mcp_store.backend.oauth.requests.post", return_value=mock_resp) as mock_post:
+ with (
+ patch("products.mcp_store.backend.oauth.is_url_allowed", return_value=(True, None)),
+ patch("products.mcp_store.backend.oauth.requests.post", return_value=mock_resp) as mock_post,
+ ):
result = refresh_oauth_token(
token_url="https://example.com/token",
refresh_token="old-refresh",
diff --git a/products/signals/backend/slack_inbox_notifications.py b/products/signals/backend/slack_inbox_notifications.py
index b0c3d45ba3d8..7e4bc472d911 100644
--- a/products/signals/backend/slack_inbox_notifications.py
+++ b/products/signals/backend/slack_inbox_notifications.py
@@ -226,7 +226,7 @@ def _resolve_suggested_reviewer_user_ids(report: SignalReport) -> set[int]:
user = entry.get("user") if isinstance(entry, dict) else None
if isinstance(user, dict) and user.get("id"):
resolved_user_ids.add(int(user["id"]))
- return resolved_user_ids
+ return set(report.team.all_users_with_access().filter(id__in=resolved_user_ids).values_list("id", flat=True))
def _own_target_configs_by_user(team_id: int, user_ids: set[int]) -> dict[int, SignalUserAutonomyConfig]:
diff --git a/products/signals/backend/test/test_slack_inbox_notifications.py b/products/signals/backend/test/test_slack_inbox_notifications.py
index e6fbe0d12ce4..dba63dd55aae 100644
--- a/products/signals/backend/test/test_slack_inbox_notifications.py
+++ b/products/signals/backend/test/test_slack_inbox_notifications.py
@@ -423,8 +423,17 @@ def test_dispatch_falls_back_to_team_channel_without_suggested_reviewers(org_and
@pytest.mark.django_db
-def test_reviewer_resolution_uses_only_the_latest_reviewer_row(org_and_team):
[email protected]("has_project_access", [True, False])
+def test_reviewer_resolution_uses_only_the_latest_reviewer_row(
+ org_and_team: tuple[Organization, Team], has_project_access: bool
+) -> None:
org, team = org_and_team
+ if not has_project_access:
+ org.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ org.save()
+ AccessControl.objects.create(team=team, resource="project", resource_id=str(team.id), access_level="none")
old_reviewer = _make_reviewer_user(org, "[email protected]", "old-reviewer")
current_reviewer = _make_reviewer_user(org, "[email protected]", "current-reviewer")
report = _make_ready_report(team, priority=AutonomyPriority.P1)
@@ -441,7 +450,7 @@ def test_reviewer_resolution_uses_only_the_latest_reviewer_row(org_and_team):
content=json.dumps([{"user_uuid": str(current_reviewer.uuid)}]),
)
- assert _resolve_suggested_reviewer_user_ids(report) == {current_reviewer.id}
+ assert _resolve_suggested_reviewer_user_ids(report) == ({current_reviewer.id} if has_project_access else set())
@pytest.mark.django_db
@@ -1116,7 +1125,13 @@ def test_reviewer_added_notifies_added_reviewer_on_own_channel(org_and_team):
@pytest.mark.django_db
-def test_reviewer_added_skips_org_member_without_project_access(org_and_team):
+ ("report_ready", "team_channel", "expected_sent"),
+ [(False, None, 0), (True, None, 0), (True, "CTEAM", 1)],
+)
+def test_notification_respects_project_access(
+ org_and_team: tuple[Organization, Team], report_ready: bool, team_channel: str | None, expected_sent: int
+) -> None:
# Org membership alone must not leak a private project's report into Slack: a member
# locked out of the project (project marked private, no explicit access) gets no ping.
org, team = org_and_team
@@ -1131,13 +1146,23 @@ def test_reviewer_added_skips_org_member_without_project_access(org_and_team):
slack_notification_integration=integration,
slack_notification_channel="C123|#inbox",
)
- report = _make_ready_report(team, priority=AutonomyPriority.P1)
+ report = _make_ready_report(team, priority=AutonomyPriority.P1, suggested_logins=["no-access-bot"])
+ if team_channel:
+ _set_team_channel(team, team_channel)
with patch("products.signals.backend.slack_inbox_notifications.SlackIntegration") as slack_cls:
- sent = dispatch_reviewer_added_notifications(str(report.id), team.id, ["no-access-bot"])
+ if report_ready:
+ sent = dispatch_inbox_item_notifications(str(report.id), team.id)
+ else:
+ sent = dispatch_reviewer_added_notifications(str(report.id), team.id, ["no-access-bot"])
- assert sent == 0
- assert slack_cls.call_count == 0
+ assert sent == expected_sent
+ assert slack_cls.call_count == expected_sent
+ if expected_sent:
+ post_message = slack_cls.return_value.client.chat_postMessage
+ post_message.assert_called_once()
+ assert post_message.call_args.kwargs["channel"] == team_channel
+ assert "Suggested reviewers" not in json.dumps(post_message.call_args.kwargs["blocks"])
@pytest.mark.django_db