Skip to content

fix: refuse setting main to a tag, and write_data cannot finish a staged create - #2233

Merged
c-thiel merged 3 commits into
mainfrom
ct/staged-commit-not-data-commit
Nov 4, 2026
Merged

c-thiel merged 3 commits into
mainfrom
ct/staged-commit-not-data-commit

Conversation

@c-thiel

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

Copy link
Copy Markdown
Member
  • A commit that sets main to a tag is refused with 400, as Iceberg Java 1.12 does. Clients cannot append to such a table.
  • write_data alone cannot finish a staged create. The commit that finishes it is checked once, with its content, so policies on a commit's properties or update kinds and batch-check see the same request as the server. This replaces the extra check without content from feat(authz): write_data allows commits without updates; a commit to astaged table needs modify #2230; nothing changes for 0.14.

Release notes

  • Bug fix: main cannot become a tag. Lakekeeper refuses a table commit that sets main to a tag with 400, as Iceberg Java 1.12 does. Iceberg clients cannot write to a table whose main is a tag.
  • For the write_data entry: write_data alone cannot finish a staged create, such as CREATE TABLE AS SELECT in Spark.

Downstream follow-up

  • UpdateKindsListing → CommitFacts, field update_kinds_listing → commit_facts.
  • CommitFacts::default() is never a data commit: only a commit the server marked with on_table as going to a live table can be one. Test helpers: every_update_for_tests() is replaced by CommitFacts::live_check_for_tests(), live_request_for_tests() and staged_request_for_tests().

Summary by CodeRabbit

  • Bug Fixes
    • Commits to staged tables now follow the authorization rules for staged-table commits, regardless of the listed update kinds. Live-table data-only commits continue to be distinguished from structural changes.
    • Setting the main reference to a tag is rejected with a clear error. Failed commits leave table metadata unchanged; tags can still be created under other reference names.
  • Documentation
    • Clarified how authorization checks apply to commits on staged tables.

… data commit

A commit to a staged table, which finishes a staged create, is never a data commit, so `write_data` cannot finish one and OpenFGA asks `modify`. The server asks the authorizer this one action with the commit's content, so a policy on properties, update kinds or refs decides on the commit that finishes the create. Batch-check marks a commit check on a staged table the same way and gives the server's answer. `UpdateKindsListing` is now `CommitFacts`, and the `update_kinds_listing` field of `CatalogTableAction::Commit` is now `commit_facts`: facts the server establishes about a commit, which no client can claim.
A table commit that sets `main` to a tag is refused with 400 (`SetMainToTagNotAllowed`), and the table does not change. Iceberg Java refuses it as well. Iceberg clients append to `main` and cannot write to a table whose `main` is a tag.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Commit authorization now uses server-established facts to classify commits and preserve update details in staged-table checks. Commit processing also rejects attempts to set the main snapshot reference to a tag.

Changes

Commit Authorization

Layer / File(s) Summary
Commit facts and classification
crates/lakekeeper/src/service/authz/mod.rs, crates/authz-openfga/src/*
CommitFacts replaces UpdateKindsListing. Data-commit classification considers update-list completeness and table state. Unit tests cover classification, serialization, audit descriptors, and OpenFGA mapping.
Authorization wiring
crates/lakekeeper/src/server/commit_tables.rs, crates/lakekeeper/src/server/tables.rs, crates/lakekeeper/src/api/management/v1/check.rs, authz/openfga/*, crates/lakekeeper-integration-tests/tests/openfga_write_data.rs
Commit requests populate CommitFacts. Checks preserve requested update details. Staged-table commits no longer receive an additional any_commit check.
Table authorization validation
crates/lakekeeper-integration-tests/tests/management_check.rs
Integration tests compare batch authorization checks with server commit outcomes for staged and live tables.

Main Reference Validation

Layer / File(s) Summary
Reject tags on the main reference
crates/lakekeeper/src/server/commit_tables.rs, crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs
apply_commit rejects setting main to a tag. Integration tests check the error, unchanged metadata after rejection, and tag creation under another reference name.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ManagementCheckAPI
  participant CatalogTableAction
  participant on_table
  participant Authorizer
  ManagementCheckAPI->>CatalogTableAction: Pass commit action and update details
  CatalogTableAction->>on_table: Bind action to table information
  on_table->>Authorizer: Pass action with commit facts
Loading

Possibly related PRs

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to f40ef

No confirmed issue currently prevents merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two changes, and both appear in the changeset. The first is refusing a commit that sets main to a tag with HTTP 400 and SetMainToTagNotAllowed, which is implemented in `commit_tabl…
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.
Full details: Title check

Explanation

The title names two changes, and both appear in the changeset. The first is refusing a commit that sets main to a tag with HTTP 400 and SetMainToTagNotAllowed, which is implemented in commit_tables.rs and tested in server_tables_postgres.rs. The second is that write_data alone cannot finish a staged create, which is implemented through the CommitFacts change in authz/mod.rs, the check.rs and tables.rs changes, and the related test updates. The title is accurate but long at 79 characters, and it joins two unrelated fixes with a comma. It is therefore a partial fit for the main change, not a full summary of the changeset. The wording of the second clause is also less precise than the objectives, which describe a staged-create commit that needs modify rather than write_data alone.

Full details: Docstring Coverage

Explanation

Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 9 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
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 each commit’s trail
With facts that mark the table state
Staged updates keep their details
Live updates take their proper gate
No tag can claim the main branch now
The rabbit hops, and tests confirm it all

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: 40ae9add-b5cb-44b6-acc4-285658b21df6
Commits

Reviewing files that changed from the base of the PR and between c924c53 and f40ef67.

Files selected for processing: 4
  • crates/authz-openfga/src/authorizer.rs
  • crates/authz-openfga/src/relations.rs
  • crates/lakekeeper-integration-tests/tests/management_check.rs
  • crates/lakekeeper/src/service/authz/mod.rs

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 4, 2026
@c-thiel c-thiel changed the title fix: check a commit to a staged table once, and refuse setting main to a tag fix: refuse setting main to a tag, and write_data cannot finish a staged create Nov 4, 2026
`CommitFacts` records the table a commit goes to as unresolved, live or staged, and only a commit to a live table can be a data commit. A place that authorizes a commit without `CatalogTableAction::on_table` therefore refuses `write_data` and asks for `modify`. The test authorizer can block every commit that is not a data commit, and batch-check and the server give the same answer for a data commit to a live and to a staged table. Tests outside the crate build commit facts with `CommitFacts::live_check_for_tests()`, `live_request_for_tests()` and `staged_request_for_tests()`.
@github-actions

github-actions Bot commented Nov 4, 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 merged commit 328ab77 into main Nov 4, 2026
76 of 79 checks passed
@c-thiel
c-thiel deleted the ct/staged-commit-not-data-commit branch November 4, 2026 14:24
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