Skip to content

fix(opa-bridge): $snapshots needs read_data; comments on views ask commit - #2238

Merged
c-thiel merged 3 commits into
mainfrom
ct/opa-bridge-015
Nov 5, 2026
Merged

c-thiel merged 3 commits into
mainfrom
ct/opa-bridge-015

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Two fixes in the Trino OPA bridge.

  • Reading the $snapshots metadata table of a table now needs read_data on the table, as $files, $manifests and $partitions already do. Its summary column can contain partition values and other values that writers add. Before, get_metadata was enough.
    • $snapshots stays at read_data for good, also when a later release lets describe see snapshot summaries with only counts and sizes. The bridge cannot filter single summary keys, and Trino loads table metadata with its own identity, so a redaction in Lakekeeper never reaches Trino users.
  • COMMENT ON VIEW and COMMENT ON COLUMN on a view now ask commit on the view. Before, COMMENT ON VIEW asked an action that views do not have, and COMMENT ON COLUMN asked a table commit on the view's name, so both were always refused.

Tests pin both: $snapshots is allowed for a principal with read_data and refused for one who may only see the table; both view comment statements are allowed for a principal who may commit to the view and refused for one who may do everything else on it.

Release notes

  • OPA bridge: reading the $snapshots metadata table through Trino needs read_data on the table. Users who may only see a table cannot read it any more, because snapshot summaries can contain partition values and other values from the data. Update the bridge policies to apply this.
  • OPA bridge: COMMENT ON VIEW and COMMENT ON COLUMN on a view through Trino work for users who may change the view (commit). Before, the bridge refused them for everyone.

Summary by CodeRabbit

  • Access Control
    • Reading snapshot metadata now requires read_data access rather than get_metadata.
    • Setting comments on views and columns now requires commit access to the view.
  • Documentation
    • Updated the permission guidance to reflect the access requirement for snapshot metadata.

The summary column of $snapshots can contain partition values and custom snapshot properties that writers add. A principal who may only see a table therefore no longer reads $snapshots through Trino; read_data on the base table is needed, as for $files and $partitions.
Trino's SetViewComment asked the view action write_data, which views do not have, so COMMENT ON VIEW was always refused. Trino stores the comment as a view property, so the bridge now asks a commit of any kind on the view.
Trino sends SetColumnComment for a column of a view too, with the view's name and nothing that says it is a view. The bridge sent it only to the table rule, which asked a table commit on the view's name, so COMMENT ON COLUMN on a view was always refused. The view rule now asks a view commit of any kind for it, as for SetViewComment; tables are decided by the table rule as before.

Also clarify which values $snapshots shows in docs/opa.md.
@cla-assistant

cla-assistant Bot commented Nov 5, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Trino OPA policies now require read_data for the $snapshots table. View and column comment operations now require commit access to the target view. Tests and documentation reflect these authorization rules.

Changes

Snapshot-table permissions

Layer / File(s) Summary
Snapshot-table read action
authz/opa-bridge/policies/trino/allow_table.rego, authz/opa-bridge/tests/trino/metadata_read_test.rego, docs/docs/opa.md
$snapshots moves from get_metadata to read_data. Tests update its classification and batch expectations, and the documentation lists it under read_data.

View-comment authorization

Layer / File(s) Summary
View-comment commit checks
authz/opa-bridge/policies/trino/allow_view.rego, authz/opa-bridge/tests/trino/metadata_table_names_test.rego, authz/opa-bridge/tests/trino/write_test.rego
SetViewComment and SetColumnComment now require commit access to the target view. Tests cover both operations, including permitted and denied commit checks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to aa240

Snapshot reads now require read_data, and view comments require commit. No actionable merge-blocking risk was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies both main changes: $snapshots requires read_data, and view comments require commit.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the snapshots page,
“Read data,” says the policy sage.
View comments pass by commit gate,
Column comments share that fate.
Tests confirm each rule in place,
Then I hop off at a steady pace.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a5512bcd-8a98-4dea-89d2-3e4976697e04
Commits

Reviewing files that changed from the base of the PR and between c674a3b and aa24019.

Files selected for processing: 6

  • authz/opa-bridge/policies/trino/allow_table.rego
  • authz/opa-bridge/policies/trino/allow_view.rego
  • authz/opa-bridge/tests/trino/metadata_read_test.rego
  • authz/opa-bridge/tests/trino/metadata_table_names_test.rego
  • authz/opa-bridge/tests/trino/write_test.rego
  • docs/docs/opa.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@c-thiel
c-thiel marked this pull request as ready for review November 5, 2026 06:48
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel enabled auto-merge (squash) November 5, 2026 07:01
@c-thiel
c-thiel merged commit 8da986d into main Nov 5, 2026
86 of 88 checks passed
@c-thiel
c-thiel deleted the ct/opa-bridge-015 branch November 5, 2026 07:32
c-thiel added a commit that referenced this pull request Nov 6, 2026
Takes the facts of the merged PRs #2238 to #2253 (write privilege, register on the warehouse, skipping soft deletion, chained INVOKER views run as the caller, storage credential action) and keeps the restructured text of this branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant