: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): only send Slack notification when report has a PR (#62505)
Joshua Snyder6ae51032e8cb
diff --git a/products/signals/backend/temporal/inbox_notification.py b/products/signals/backend/temporal/inbox_notification.pyindex c02cd288f458..66118404383e 100644--- a/products/signals/backend/temporal/inbox_notification.py+++ b/products/signals/backend/temporal/inbox_notification.py@@ -1,10 +1,12 @@"""Decides when (and whether) to send a report's inbox Slack notification.-A report that auto-starts an implementation task waits for the PR to open (so the card can-carry a "Review PR" button), bounded by a timeout. If that task never opens a PR (it fails,-is cancelled, or the wait times out), no notification is sent — there's nothing actionable to-link. A report with no auto-start task notifies immediately. Posting itself stays in-`dispatch_inbox_item_notifications`; this governs timing and suppression.+A notification is only sent when the report has an implementation PR to link — otherwise+there's nothing actionable, so it's suppressed (it still appears in the inbox UI). A report+that auto-starts an implementation task waits for the PR to open (so the card can carry a+"Review PR" button), bounded by a timeout; if that task never opens a PR (it fails, is+cancelled, or the wait times out) the notification is suppressed. A report with no auto-start+task can never produce a PR, so it's suppressed immediately without waiting. Posting itself+stays in `dispatch_inbox_item_notifications`; this governs timing and suppression."""from __future__ import annotations@@ -135,12 +137,21 @@ class SignalReportInboxNotificationWorkflow:if state.pr_available or state.task_terminal:break- # An implementation task that never opened a PR (failed, cancelled, or timed out) has- # nothing actionable to link, so suppress its notification. `workflow.patched` keeps- # in-flight workflows from before this change on the previous always-notify behavior.- if workflow.patched("signals-inbox-skip-no-pr") and state.has_implementation_task and not state.pr_available:+ # A report with no implementation PR has nothing actionable to link, so suppress its+ # notification (it still shows in the inbox). The patch guards keep workflows already in+ # flight at deploy on their prior, narrower behavior to preserve replay determinism:+ # `signals-inbox-skip-any-no-pr` suppresses any PR-less report; the older+ # `signals-inbox-skip-no-pr` only suppressed reports whose implementation task produced no PR.+ if workflow.patched("signals-inbox-skip-any-no-pr"):+ should_skip = not state.pr_available+ elif workflow.patched("signals-inbox-skip-no-pr"):+ should_skip = state.has_implementation_task and not state.pr_available+ else:+ should_skip = False++ if should_skip:workflow.logger.info(- "inbox notification skipped: implementation task produced no PR",+ "inbox notification skipped: no implementation PR to link",extra={"report_id": inputs.report_id, "team_id": inputs.team_id},)return 0diff --git a/products/signals/backend/test/test_inbox_notification_workflow.py b/products/signals/backend/test/test_inbox_notification_workflow.pyindex 81288fe4c5fc..a2d70eaaaa8c 100644--- a/products/signals/backend/test/test_inbox_notification_workflow.py+++ b/products/signals/backend/test/test_inbox_notification_workflow.py@@ -133,16 +133,6 @@ PR_READY = InboxNotificationState(has_implementation_task=True, pr_available=TruTERMINAL = InboxNotificationState(has_implementation_task=True, pr_available=False, task_terminal=True)-@override_settings(SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=10, SIGNALS_INBOX_PR_NOTIFICATION_POLL_SECONDS=1)-async def test_workflow_notifies_immediately_without_task():- recorder = _Recorder([NO_TASK])- sent = await _run_workflow(recorder)- assert sent == 1- assert recorder.state_calls == 1 # no polling- assert recorder.dispatch_calls == 1--@pytest.mark.asyncio@override_settings(SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=10, SIGNALS_INBOX_PR_NOTIFICATION_POLL_SECONDS=1)async def test_workflow_waits_then_notifies_when_pr_opens():@@ -155,13 +145,14 @@ async def test_workflow_waits_then_notifies_when_pr_opens():@pytest.mark.asyncio@pytest.mark.parametrize(- "states,timeout_seconds",+ "states,timeout_seconds,polls",[- ([WAIT, TERMINAL], 10), # task reaches a terminal state without ever opening a PR- ([WAIT], 3), # PR never opens, so the wait runs out the timeout+ ([NO_TASK], 10, False), # a task-less report can never produce a PR, so skip on the first fetch+ ([WAIT, TERMINAL], 10, True), # task reaches a terminal state without ever opening a PR+ ([WAIT], 3, True), # PR never opens, so the wait runs out the timeout],)-async def test_workflow_skips_when_no_pr_is_produced(states, timeout_seconds):+async def test_workflow_skips_when_no_pr_is_produced(states, timeout_seconds, polls):recorder = _Recorder(states)with override_settings(SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=timeout_seconds,@@ -169,5 +160,8 @@ async def test_workflow_skips_when_no_pr_is_produced(states, timeout_seconds):):sent = await _run_workflow(recorder)assert sent == 0- assert recorder.state_calls >= 2 # initial fetch + at least one poll before giving upassert recorder.dispatch_calls == 0+ if polls:+ assert recorder.state_calls >= 2 # initial fetch + at least one poll before giving up+ else:+ assert recorder.state_calls == 1 # decided on the first fetch — no task means no polling