fix(tag_masking_policy_reference): treat a missing database as not-created-yet - #79
Conversation
…eated-yet Querying <database>.INFORMATION_SCHEMA.POLICY_REFERENCES for a tag's own database fails with INVALID_IDENTIFIER (2004), not DOES_NOT_EXIST_ERR (2003), when that database doesn't exist yet -- e.g. a fresh account where the same config creates the database and declares the masking policy reference in one plan. This mirrors the existing DOES_NOT_EXIST_ERR handling used for roles.
Review of PR #79No issues found. This is a small, well-scoped fix: The change correctly narrows to |
What
fetch_tag_masking_policy_referenceandlist_tag_masking_policy_referencesnow treat Snowflake'sINVALID_IDENTIFIER(2004) the same asDOES_NOT_EXIST_ERR(2003): a reference that can't be read yet, not a fatal error.Why
On a fresh Snowflake account,
snowcap planaborted as soon as a config declared tag masking policy references:Snowcap reads each reference's state from inside the tag's own database (
<database>.INFORMATION_SCHEMA.POLICY_REFERENCES), but that database doesn't exist yet when the same config is also the one creating it. Snowflake can't resolve the qualified table function name in that case, so it returnsINVALID_IDENTIFIERrather thanDOES_NOT_EXIST_ERR.Snowcap already handles the equivalent case for roles (missing role → 2003, keeps going). This extends the same "not created yet" treatment to the masking-policy-reference path, so a first plan/apply against a fresh account no longer requires the
--exclude tag_masking_policy_referenceworkaround.Verified
TestTagMaskingPolicyReferenceMissingDatabaseintests/test_data_provider.py, reproducing the exact002004error and confirming it's swallowed for both the fetch and list paths, while otherProgrammingErrors still raise.make lint,make typecheck, and the full test suite (2227 passed) all clean.