: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(data-warehouse): show refresh mode under read-only impersonation (#103782)
Luke Belton823c183ea066
diff --git a/posthog/middleware.py b/posthog/middleware.pyindex e7252c40ab32..2f090496d9f9 100644--- a/posthog/middleware.py+++ b/posthog/middleware.py@@ -1766,6 +1766,15 @@ READ_ONLY_IMPERSONATION_ALLOWLISTED_PATHS: list[tuple[str, str | re.Pattern]] =r"^/api/(environments|projects)/([0-9]+|@current)/external_data_schemas/[^/]+/incremental_fields/?$"),),+ # POST but read-only: parses the query's SQL to report whether it can be materialized+ # incrementally, and writes nothing. The editor calls it on every open of a model's+ # materialization panel, so blocking it hides the whole Refresh mode section with no error.+ # The action is named exactly, because the same prefix hosts the mutating saved-query+ # actions (materialize, run, cancel, resume).+ (+ "POST",+ re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/warehouse_saved_queries/check_incremental/?$"),+ ),# 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: the Logs product sends its queries as POST because the filter payloaddiff --git a/posthog/test/test_middleware.py b/posthog/test/test_middleware.pyindex b0ddd4feb1a4..89efe91b5a37 100644--- a/posthog/test/test_middleware.py+++ b/posthog/test/test_middleware.py@@ -1078,6 +1078,11 @@ class TestImpersonationReadOnlyMiddleware(APIBaseTest):"external_data_schemas/00000000-0000-0000-0000-000000000000/incremental_fields/",{},),+ (+ "warehouse_saved_queries_check_incremental",+ "warehouse_saved_queries/check_incremental/",+ {"query": "select 1"},+ ),("exports","exports/",@@ -1110,13 +1115,17 @@ class TestImpersonationReadOnlyMiddleware(APIBaseTest):("logs_alerts", "logs/alerts/"),("logs_views", "logs/views/"),("logs_sampling_rules", "logs/sampling_rules/"),+ (+ "warehouse_saved_query_materialize",+ "warehouse_saved_queries/00000000-0000-0000-0000-000000000000/materialize/",+ ),])- def test_read_only_impersonation_blocks_logs_crud_siblings(self, _name, path_suffix):+ def test_read_only_impersonation_blocks_mutating_siblings(self, _name, path_suffix):self.login_as_other_user_read_only()- # The logs query allowlist enumerates action names precisely because the same- # `logs/` prefix hosts these writing viewsets.+ # Every allowlist entry names its action exactly, because each of these prefixes also+ # hosts mutating actions. Widening one to its prefix would reach these.response = self.client.post(f"/api/projects/{self.team.id}/{path_suffix}",data={},