chore(data-warehouse): allow incremental_fields during read-only impersonation#60423
Merged
sakce merged 2 commits intoMay 28, 2026
Merged
Conversation
…rsonation The external_data_schemas `incremental_fields` action is a POST but performs no PostHog-side mutations — it validates the source's credentials and lists schemas against the customer's external source to return metadata about available incremental fields and columns. Allowlist its path in `READ_ONLY_IMPERSONATION_ALLOWLISTED_PATHS`, alongside the other "POST but read-only" entries (query, batch_by_distinct_ids, error_tracking/stack_frames/batch_get), so support engineers can inspect the response while impersonating a customer read-only. Generated-By: PostHog Code Task-Id: 2c660a12-b953-466c-8f9d-c9f11b912554
Contributor
|
Reviews (1): Last reviewed commit: "chore(data-warehouse): allow incremental..." | Re-trigger Greptile |
Contributor
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
Collapse the new incremental_fields allowlist regex to a single line so `ruff format` is happy. Ruff prefers a single-line `re.compile(...)` for regex literals at this width, matching the surrounding entries. Generated-By: PostHog Code Task-Id: 2c660a12-b953-466c-8f9d-c9f11b912554
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When support engineers impersonate a customer in read-only mode, the
POST /api/environments/:project/external_data_schemas/:id/incremental_fields/endpoint is blocked by
ImpersonationReadOnlyMiddleware. The block makes itimpossible to inspect what the UI would receive when picking incremental sync
fields for a customer — which is exactly the kind of question support sessions
are for.
The endpoint is POST but doesn't write anything PostHog-side: it loads the
schema, validates the source's credentials, calls
new_source.get_schemas()against the customer's external source, and returns metadata (available
incremental fields, supported sync types, columns).
Changes
external_data_schemas/<id>/incremental_fields/regex toREAD_ONLY_IMPERSONATION_ALLOWLISTED_PATHSinposthog/middleware.py,alongside the other "POST but read-only" entries.
TestImpersonationReadOnlyMiddlewarethatasserts the path is not blocked with
impersonation_read_onlyduring aread-only impersonation session.
The endpoint does fire an outbound credential-validation call to the
customer's source; that's still "read" from PostHog's perspective, but worth
knowing if rate limits on the customer's side are a concern during a support
session.
How did you test this code?
I'm an agent. I added an automated test (the new parameterized row in
test_read_only_impersonation_allows_allowlisted_post) and verified the newregex pattern matches the intended URL shape (with
[0-9]+and@currentproject segments, with and without a trailing slash) and rejects unrelated
paths in a local Python check. I did not run the test suite locally (no
Python venv available in the sandbox) — relying on CI to run it.
Publish to changelog?
no
🤖 Agent context
Authored by Claude Opus 4.7 via PostHog Code. The user asked whether
incremental_fieldsneeded to be gated by the impersonation block or couldbe allowlisted; I confirmed the endpoint body has no PostHog-side writes
(only validates external credentials and lists schemas) so it matches the
existing "POST but read-only" allowlist pattern used for
query/,persons/batch_by_distinct_ids/, anderror_tracking/stack_frames/batch_get/.The user then asked me to ship the change.
Decisions:
environmentsandprojectsvariantsof the URL, mirroring neighbouring entries.
surface tight.
scope_object_write_actionson the viewset — that's apermissions/scope concern, separate from the impersonation block, and out
of scope for this change.