Emit the views ACL section - #62
Conversation
schemata/acls.yml accepts a views: key and models::Acls carries the field, but build's SECTIONS never listed it, so a hand-authored view grant validated, loaded, and was then silently discarded — the same failure mode as the role membership gap fixed in #58. There is no panic to surface it: section()'s unreachable! fires only for a name present in SECTIONS, and views was absent from SECTIONS entirely, so the field was simply never read. Emit it as part of the tables section rather than as a section of its own. PostgreSQL grants on views with TABLE syntax — which is why pull already writes view grants under tables: — so views: is a spelling of the same statement, not a different one. A dedicated SECTIONS entry would give a view named under both keys two ACL entries carrying the same tag; feeding both fields into one bucket coalesces them into the single entry the object warrants. Verified end to end: a project granting SELECT under views: restores into PostgreSQL 17 with the privilege present on the view. Fixes #60 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: 8 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour. 📝 WalkthroughWalkthroughThe ACL builder now emits grants declared under ChangesView ACL emission
Merge Risk: ⚪ Minimal · up to The change adds support for emitting view grants through the existing table-grant path and reports passing checks; no actionable merge-blocking risk remains beyond normal review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR satisfies issue Full details: Docstring CoverageExplanation Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 1 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Summary
schemata/acls.yml:134accepts aviews:key andmodels::Aclscarries the field, but
src/build/acls.rs'sSECTIONSnever listed it,so a hand-authored view grant validated, loaded, and was then silently
discarded. Same failure mode as the role membership gap fixed in #58.
Fixes #60.
Problem
Three places have to agree on a section name and only two did:
schemata/acls.yml:134definesviews:(schema.name→[SELECT|ALL])src/models/roles.rs:41carriespub views: Option<Map<String, Value>>SECTIONShad 13 entries and noviewsamong themNothing surfaced it.
section()'sunreachable!fires only for a namepresent in
SECTIONS, andviewswas absent fromSECTIONSentirely,so the field was never read — no error, no warning, no entry.
Solution
Emit it as part of the
tables:section rather than as a section ofits own, which is the part worth reviewing.
PostgreSQL grants on views with
TABLEsyntax —GRANT SELECT ON VIEW xis not valid SQL — which is why
pullalready routes view grants totables:viasection_key(). Soviews:is an alternate spelling ofthe same statement, not a different statement. A dedicated
SECTIONSentry would emit correct SQL but give a view named under both keys two
ACL entries carrying the same
TABLE <name>tag; feeding both fieldsinto one bucket coalesces them into the single entry the object
warrants.
The mechanism is a
coalesced()companion to the existingsection():RELATIONSalready coversTable/View/MaterializedView, sodependency resolution and entry ownership needed no change.
I did not take option 2 from the issue (delete
views:from the schema).The schemata are a contract carried over from Python unchanged, and
additionalProperties: falsemakes removing a key breaking for anyproject that hand-authored it — a much larger blast radius than the bug.
Tests
emits_grants_from_the_views_section— aviews:grant reaches thearchive as
GRANT ... ON TABLE, in the view's namespace, with theview's owner and a dependency edge on the view's entry.
views_and_tables_sections_coalesce_into_one_entry— the same viewunder both keys yields exactly one ACL entry.
Renamed the test helper
membership_project→project_with(added in#58, test-only, mechanical): it builds a project from an inventory and is
no longer membership-specific now that the views tests use it too.
Verification
just check(fmt-check + clippy-D warnings+ test) — clean.End to end against PostgreSQL 17, since unit tests here only prove
the TOC. Built a minimal project granting
SELECTunderviews:andrestored it:
Restore completed with no errors.
just docsnot run — mkdocs is not installed in this environment. Thedocs change is one bullet in an existing list with no new links or nav
entries, so
--stricthas nothing new to resolve, but CI shouldconfirm.
Summary by CodeRabbit
New Features
tablesorviews.tableswhen configurations are pulled.Documentation