: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(workflows): size audiences during read-only impersonation (#105799)
Luke Belton4a4c1c500f50
diff --git a/posthog/middleware.py b/posthog/middleware.pyindex ff343d25ae39..014dea037081 100644--- a/posthog/middleware.py+++ b/posthog/middleware.py@@ -1929,6 +1929,9 @@ READ_ONLY_IMPERSONATION_ALLOWLISTED_PATHS: list[tuple[str, str | re.Pattern]] =("POST", re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/experiments/setup_context/?$")),# POST but read-only: kicks off insight/dashboard/session replay export renders (e.g. MP4)("POST", re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/exports/?$")),+ # POST but read-only: counts the persons a workflow audience matches. The action is named+ # exactly, because the same `hog_flows/` prefix hosts the writing actions (publish, run).+ ("POST", re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/hog_flows/user_blast_radius/?$")),# POST but read-only: the Logs product sends its queries as POST because the filter payload# is too large for a query string. Action names are enumerated rather than allowing the whole# `logs/` prefix, which also hosts writing CRUD viewsets (alerts, views, sampling_rules,diff --git a/posthog/test/test_middleware.py b/posthog/test/test_middleware.pyindex 5bce9d089c40..ad3789014374 100644--- a/posthog/test/test_middleware.py+++ b/posthog/test/test_middleware.py@@ -1092,6 +1092,7 @@ class TestImpersonationReadOnlyMiddleware(APIBaseTest):"exports/",{"export_format": "video/mp4", "export_context": {"session_recording_id": "test-session"}},),+ ("hog_flows_user_blast_radius", "hog_flows/user_blast_radius/", {}),("logs_query", "logs/query/", {}),# hyphenated action that the shorter `count` alternative must not shadow("logs_count_ranges", "logs/count-ranges/", {"query": "not-a-dict"}),@@ -1125,6 +1126,8 @@ class TestImpersonationReadOnlyMiddleware(APIBaseTest):"warehouse_saved_queries/00000000-0000-0000-0000-000000000000/materialize/",),("experiments_create", "experiments/"),+ ("hog_flow_publish", "hog_flows/00000000-0000-0000-0000-000000000000/publish/"),+ ("hog_flow_bulk_delete", "hog_flows/bulk_delete/"),])def test_read_only_impersonation_blocks_mutating_siblings(self, _name, path_suffix):