Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: database grant read #2063

Merged
merged 6 commits into from
Sep 28, 2023
Merged

fix: database grant read #2063

merged 6 commits into from
Sep 28, 2023

Conversation

sfc-gh-swinkler
Copy link
Collaborator

fixes #1863
grantee type "database_role" was not recognized in the switch/case statement. adding a default fixes that.

before:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: error reading database grant: unknown grantee type DATABASE_ROLE
│
│   with snowflake_database_grant.grant,
│   on main.tf line 38, in resource "snowflake_database_grant" "grant":
│   38: resource "snowflake_database_grant" "grant" {
│
╵

after:

No changes. Your infrastructure matches the configuration.

@github-actions
Copy link

Integration tests success for 036ace51b99d49a14b78a7629922c93db71bd25e

@@ -187,6 +187,8 @@ func readGenericGrant(
privileges.addString(grant.Privilege)
// Reassign set back
sharePrivileges[granteeNameStrippedAccount] = privileges
default:
log.Printf("[WARN] unexpected grantee type: %s", grant.GranteeType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the DATABASE ROLE type as a separate branch in this switch statement, not the default one. We can leave the default one, too, for future grantee types, but I would prefer having it explicit.

@@ -187,6 +187,8 @@ func readGenericGrant(
privileges.addString(grant.Privilege)
// Reassign set back
sharePrivileges[granteeNameStrippedAccount] = privileges
default:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the default case fixes the issue ? Right now, the program behaviour is the same except it logs on unknown case in switch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this was already fixed in https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/2037/files
released as part of 0.70.1.

I guess this PR is not needed. it does make it more explicit though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in the pr you've linked there's also only change with just logging which shouldn't break / fix anything, right ? I don't understand why this or linked pr is fixing anything

@github-actions
Copy link

Integration tests failure for fbbbbe32f47686ec9bca0feeeb9b4d32055b493f

@github-actions
Copy link

Integration tests failure for 35a02b89f1697f9a0ff54a0cf7d1865e09579952

@github-actions
Copy link

Integration tests failure for cb8a8ef959ed3489a7bc71a19df849486efc53ad

@github-actions
Copy link

Integration tests failure for 53adedbbc356ae34df46c726dc7983e816193044

@github-actions
Copy link

Integration tests failure for b6cc73f7727de3f275c7e1b016d377e13bf61d4a

@sfc-gh-swinkler sfc-gh-swinkler merged commit d93ddd5 into main Sep 28, 2023
7 of 8 checks passed
@sfc-gh-swinkler sfc-gh-swinkler deleted the issue-1863 branch September 28, 2023 18:10
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.

Grant read operation fails when a privilege has been granted to a database role
3 participants