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(experiments): scope the activity leak assertion to experiment entries (#97030)

posthog[bot]78c74caca046
diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.py
index 469b079d5dce..909e33e1f6ec 100644
--- a/products/experiments/backend/test/test_presentation_api.py
+++ b/products/experiments/backend/test/test_presentation_api.py
@@ -7147,7 +7147,11 @@ class TestExperimentAuxiliaryEndpoints(_HoistFlagConfigClientMixin, ClickhouseTe
results = response.json()["results"]
item_ids = {entry["item_id"] for entry in results}
- self.assertNotIn(str(other_experiment_id), item_ids)
+ # Scoped, because experiments and feature flags number from separate sequences and so reuse
+ # each other's ids. Matching the id alone reads this experiment's own flag entry as the
+ # unrelated experiment leaking in, whenever the two sequences happen to line up.
+ experiment_item_ids = {entry["item_id"] for entry in results if entry["scope"] == "Experiment"}
+ self.assertNotIn(str(other_experiment_id), experiment_item_ids)
self.assertLessEqual(item_ids, {str(experiment_id), str(holdout_id), str(saved_metric_id), str(flag_id)})
flag_entries = [entry for entry in results if entry["scope"] == "FeatureFlag"]
self.assertEqual({entry["item_id"] for entry in flag_entries}, {str(flag_id)})