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.

chore(data-warehouse): allow incremental_fields during read-only impersonation (#60423)

Jovan Sakovicdc62d18de6b4
diff --git a/posthog/middleware.py b/posthog/middleware.py
index 84730e7fba6c..46944d32eaf6 100644
--- a/posthog/middleware.py
+++ b/posthog/middleware.py
@@ -1185,6 +1185,10 @@ READ_ONLY_IMPERSONATION_ALLOWLISTED_PATHS: list[str | re.Pattern] = [
re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/persons/batch_by_distinct_ids/?$"),
# POST but read-only: loads stack frame records (source context) for error tracking UI
re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/error_tracking/stack_frames/batch_get/?$"),
+ # POST but read-only: returns metadata about available incremental fields / columns
+ # for a data warehouse schema. Validates external credentials and lists schemas
+ # against the customer's source — no PostHog-side mutations.
+ re.compile(r"^/api/(environments|projects)/([0-9]+|@current)/external_data_schemas/[^/]+/incremental_fields/?$"),
# Allow upgrading from read-only to read-write impersonation
"/admin/impersonation/upgrade/",
# Logout is POST in Django 5; the frontend submits to `/logout` (no trailing slash),
diff --git a/posthog/test/test_middleware.py b/posthog/test/test_middleware.py
index d901ded837fc..2f9886c40462 100644
--- a/posthog/test/test_middleware.py
+++ b/posthog/test/test_middleware.py
@@ -785,6 +785,11 @@ class TestImpersonationReadOnlyMiddleware(APIBaseTest):
("query", "query/", {"query": {"kind": "EventsQuery", "select": ["event"]}}),
("query_kind", "query/HogQLQuery/", {"query": {"kind": "HogQLQuery", "query": "select 1"}}),
("endpoint_materialization_preview", "endpoints/some_endpoint/materialization_preview/", {}),
+ (
+ "external_data_schemas_incremental_fields",
+ "external_data_schemas/00000000-0000-0000-0000-000000000000/incremental_fields/",
+ {},
+ ),
]
)
def test_read_only_impersonation_allows_allowlisted_post(self, _name, path_suffix, body):