fix(data_provider): correct fetch_grant matching for FUTURE and integration grants - #66
Conversation
…n grants Live verification showed Snowflake's SHOW GRANTS collapses all *-integration types to granted_on='INTEGRATION' (not the spaced label), while GIT_REPOSITORY keeps its underscore — the initial space-normalization fix was wrong for both. fetch_grant now keeps a separate query form (bare 'INTEGRATION' for *_integration labels, uppercased label otherwise) from the canonical spaced form returned for diffing. Tests updated to assert the real live forms; all four cases verified matching against the live account.
Superpowers code review + full Ponytail reviewVerdict: changes required before merge. Superpowers — Important
Superpowers — Required test coverage
The targeted Ponytail — Required simplifications
Please address both the correctness and Ponytail findings before merge. |
Address PR review:
- FUTURE grant container inference and parse_collection_string now use
smart_split, so quoted identifiers containing dots
('"DB.WITH.DOT".<SCHEMA>') classify correctly instead of
mis-parsing and preserving the phantom create.
- Cover the ALL+FUTURE database-role branch and the ALL-on-integration
_filter_result branch.
- Reuse the _grant_to_role_row fixture and parameterize the five
object-type round-trip tests.
- Regression tests for quoted identifiers at both database and schema
container level, and for parse_collection_string.
|
All findings addressed in 352d54f. Quote-aware parsing (Important): Verified — the raw Test coverage: Added Ponytail simplifications: Dropped both new row factories — Full suite green: 2063 passed. |
noel
left a comment
There was a problem hiding this comment.
Superpowers re-review + Ponytail
Verdict: approved.
Superpowers
No Critical or Important findings. The current head (352d54f) addresses the prior review:
- routes
ALL + FUTUREthrough the correct role/database-role SHOW helpers - keeps Snowflake query labels separate from canonical returned object types
- uses quote-aware splitting for FUTURE container inference and collection parsing
- covers the missing database-role and integration branches
Fresh focused verification: 363 passed (tests/test_data_provider.py, tests/test_parse.py, tests/test_identifiers.py). Hosted Python 3.10/3.11/3.12 and security checks are also green.
Minor, non-blocking
tests/test_data_provider.py:2882: quote-aware inference directly exercises the role helper but not the duplicated database-role helper. Both production helpers contain the same change; parameterize this test over both only if branch-specific regression coverage becomes necessary.
Ponytail
Lean already. Ship.
Problem
Two grant-matching bugs in
fetch_grantcause phantom creates duringplan/apply: grants that exist remotely are reported missing, so snowcap re-creates (or in sync mode, mishandles) them on every run.ALL + FUTURE grants query the wrong SHOW command. A FUTURE grant (e.g.
GRANT ALL ON FUTURE SCHEMAS IN DATABASE) was looked up viaSHOW GRANTS TO ROLEinstead ofSHOW FUTURE GRANTS, so it never matched its remote counterpart.Multi-word
on_typenever matches SHOW GRANTS output. Snowflake reportsgranted_on='CATALOG INTEGRATION'/'STORAGE INTEGRATION'(and collapses all *-integration types toINTEGRATIONin some query forms), while the URN usescatalog_integration. The underscore form was compared verbatim, so integration grants never matched.Note: a third fix originally on this branch (drop uncovered object grants during grant sync) was dropped — PR #58 already restructured that logic and added equivalent regression coverage (
test_uncovered_object_grants_are_still_dropped).Fix
on_typeto Snowflake's SHOW GRANTS form (upper().replace('_', ' ')) before filtering._show_future_grants_to_role/_show_future_grants_to_database_role.INTEGRATIONlabel where Snowflake requires it.Tests
TestFetchGrantcases: ALL+FUTURE schemas, catalog/storage integration matching, and regression checks that ACCOUNT and SCHEMA grants still match.