: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(slack_app): skip user resolution for Slack's U00 placeholder author (#76513)
Vojta Bartoš90ba5798bc4d
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex 9fa56b647729..4488de75fd64 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -127,6 +127,12 @@ HANDLED_EVENT_TYPES = [# needs, so both surfaces share one kind.SLACK_INTEGRATION_KIND = "slack"+# Slack substitutes this placeholder for the message author in ``link_shared``+# events it cannot attribute to a real user — messages posted by apps and bots,+# or authors whose identity is hidden. Calling ``users.info`` on it always+# fails with ``user_not_found``.+SLACK_PLACEHOLDER_USER_ID = "U00"+# Onboarding-on-join dedupe TTL: just long enough to absorb Slack retries and# a near-simultaneous cross-region race during cutover. A real re-add after# this window should re-onboard — most likely the person forgot how it works.@@ -356,6 +362,11 @@ def resolve_slack_user(post_feedback: bool = True,) -> SlackUserContext | None:"""Resolve a Slack user to a PostHog user. Posts an ephemeral error message and returns None on failure (unless post_feedback is False)."""+ if slack_user_id == SLACK_PLACEHOLDER_USER_ID:+ # There is no real user behind the placeholder, so there is nobody to+ # resolve or to post feedback to.+ return None+try:slack_team_id = integration.integration_id@@ -409,7 +420,7 @@ def resolve_slack_user(slack_email = dev_emailif not slack_email:- logger.exception("slack_app_no_user_email", slack_user_id=slack_user_id)+ logger.warning("slack_app_no_user_email", slack_user_id=slack_user_id)if post_feedback:_post_slack_user_feedback(slack,diff --git a/products/slack_app/backend/tests/test_resolve_slack_user.py b/products/slack_app/backend/tests/test_resolve_slack_user.pyindex 161c702f4704..5d85f1d0a32b 100644--- a/products/slack_app/backend/tests/test_resolve_slack_user.py+++ b/products/slack_app/backend/tests/test_resolve_slack_user.py@@ -77,6 +77,19 @@ class TestResolveSlackUser:mock_client.chat_postMessage.assert_called_once()assert "email" in mock_client.chat_postMessage.call_args.kwargs["text"].lower()+ @patch("posthog.models.integration.WebClient")+ def test_placeholder_user_skipped_silently(self, mock_webclient_class):+ mock_client = MagicMock()+ mock_webclient_class.return_value = mock_client++ slack = SlackIntegration(self.integration)+ result = resolve_slack_user(slack, self.integration, "U00", "C001", "1234.5678")++ assert result is None+ mock_client.users_info.assert_not_called()+ mock_client.chat_postMessage.assert_not_called()+ mock_client.chat_postEphemeral.assert_not_called()+@patch("posthog.models.integration.WebClient")def test_no_org_membership(self, mock_webclient_class):mock_client = MagicMock()