Skip to content

fix: bypass access control for materialization transforms#66390

Open
a-lider wants to merge 3 commits into
masterfrom
fix/endpoints-materialization-access-bypass
Open

fix: bypass access control for materialization transforms#66390
a-lider wants to merge 3 commits into
masterfrom
fix/endpoints-materialization-access-bypass

Conversation

@a-lider

@a-lider a-lider commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Endpoint materialization transforms run without a request user. If HogQL resolution needs warehouse tables/views in that trusted background path, resolving with normal request-scoped access control can fail because there is no user context.

Observed examples in Error tracking include the endpoint materialization transform stack under ResolutionError: Unknown table web_vitals_mv. That issue also contains older non-materialization occurrences, so this PR targets the materialization-transform path specifically.

Changes

Set bypass_warehouse_access_control=True while compiling HogQL for endpoint materialization transforms.

How did you test this code?

Tests

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No

Let trusted endpoint materialization transforms resolve warehouse HogQL sources when running without a request user.
@a-lider a-lider self-assigned this Jun 26, 2026
@a-lider a-lider changed the title fix(endpoints): bypass access control for materialization transforms fix: bypass access control for materialization transforms Jun 26, 2026
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(endpoints): bypass access control fo..." | Re-trigger Greptile

Comment on lines +73 to +75
# Userless endpoint materialization transform; bypass warehouse HogQL access control so
# the transformed query can resolve source warehouse tables/views before materialization.
bypass_warehouse_access_control=True,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing regression test for access-control bypass

There is no test that verifies _print_materialized_hogql (or build_endpoint_hogql) succeeds when warehouse access control is enabled and no user is present. A future refactor that removes or negates this flag would silently reintroduce the failure with no test catching it.

A targeted test in test_endpoint_materialization.py could mock Database.create_for to assert it is called with bypass_warehouse_access_control=True, or mock HogQLDatabaseSources.is_hogql_warehouse_access_control_enabled to True and confirm the materialization pipeline still returns a valid HogQL string.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test_materialization_transform_compiles_warehouse_table_without_user_context

@a-lider a-lider marked this pull request as ready for review June 26, 2026 16:31
@a-lider a-lider added the stamphog Request AI approval (no full review) label Jun 26, 2026
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 26, 2026 16:31
github-actions[bot]
github-actions Bot previously approved these changes Jun 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small targeted fix setting a bypass flag for a userless materialization context; the flag name and comment clearly explain the intent. The bot comment about missing tests is a valid suggestion but not a showstopper.

@sakce sakce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sakce approved this PR from Slack with Graphite

@stamphog

stamphog Bot commented Jun 26, 2026

Copy link
Copy Markdown

Retaining stamphog approval — delta since last review classified as trivial_paths.

Comment thread products/endpoints/backend/materialization_transforms.py Outdated
@veria-ai

veria-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@github-actions github-actions Bot dismissed their stale review June 26, 2026 17:24

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No showstoppers. The PR fixes a security gap by threading user context through the materialization pipeline so warehouse ACL is enforced for user-triggered operations, while Temporal's userless internal rebuilds use an explicit bypass flag. The inline review concerns (all marked outdated) were addressed in the current diff, tests cover both enforcement and bypass paths.

@a-lider a-lider enabled auto-merge (squash) June 26, 2026 17:32
@a-lider a-lider disabled auto-merge June 26, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants