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(data-warehouse): pass group_properties to digest rollout flag (#64104)

Marcus Hofa873ea8eb010
diff --git a/posthog/tasks/email.py b/posthog/tasks/email.py
index 5614e7590b94..04a17a541b24 100644
--- a/posthog/tasks/email.py
+++ b/posthog/tasks/email.py
@@ -674,10 +674,22 @@ def send_external_data_failure_digest(team_id: int, schemas: list[dict[str, Any]
# Rollout gate (absent flag = off). Gated teams are never stamped, so when the
# flag opens up the catch-up delivers their currently-failing schemas naturally.
+ # group_properties mirror the warehouse-pipelines-v3 gate (create_job_model.py):
+ # without them, release conditions on the project/organization group can't match,
+ # because the analytics group records are keyed by uuid rather than team_id/org_id.
if not settings.TEST and not posthoganalytics.feature_enabled(
key="external-data-failure-digest-email",
distinct_id=str(team.uuid),
groups={"organization": str(team.organization_id), "project": str(team.id)},
+ group_properties={
+ "organization": {"id": str(team.organization_id)},
+ "project": {"id": str(team.id)},
+ },
+ only_evaluate_locally=False,
+ # This gate fires once per failed-sync digest run; a $feature_flag_called
+ # event each time would be pure volume with no operational value (we monitor
+ # via the EXTERNAL_DATA_FAILURE_DIGEST_* metrics instead). Matches the v3 gate.
+ send_feature_flag_events=False,
):
EXTERNAL_DATA_FAILURE_DIGEST_COUNTER.labels(outcome="flag_disabled").inc()
return False
diff --git a/posthog/tasks/test/test_email.py b/posthog/tasks/test/test_email.py
index 6461d6e5b94d..35b389e8ec7d 100644
--- a/posthog/tasks/test/test_email.py
+++ b/posthog/tasks/test/test_email.py
@@ -652,6 +652,12 @@ class TestEmail(APIBaseTest, ClickhouseTestMixin):
assert len(mocked_email_messages) == expected_emails
assert mock_flag.call_args.kwargs["key"] == "external-data-failure-digest-email"
assert mock_flag.call_args.kwargs["groups"]["project"] == str(self.team.pk)
+ # group_properties must be passed so project/organization release conditions can match.
+ assert mock_flag.call_args.kwargs["group_properties"]["project"]["id"] == str(self.team.pk)
+ assert mock_flag.call_args.kwargs["group_properties"]["organization"]["id"] == str(self.team.organization_id)
+ # Network fallback stays on, and the high-frequency gate must not emit $feature_flag_called events.
+ assert mock_flag.call_args.kwargs["only_evaluate_locally"] is False
+ assert mock_flag.call_args.kwargs["send_feature_flag_events"] is False
def test_send_external_data_failure_digest_skips_when_already_sent_today(self, MockEmailMessage: MagicMock) -> None:
mocked_email_messages = mock_email_messages(MockEmailMessage)