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

Provider v0.84.0 crashes when running snowflake_grant_database_role #2402

Closed
adrianhicken opened this issue Jan 23, 2024 · 6 comments · Fixed by #2511 or #2513
Closed

Provider v0.84.0 crashes when running snowflake_grant_database_role #2402

adrianhicken opened this issue Jan 23, 2024 · 6 comments · Fixed by #2511 or #2513
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@adrianhicken
Copy link

adrianhicken commented Jan 23, 2024

Terraform CLI and Provider Versions

Terraform v1.6.4 on darwin_arm64

Provider version v0.84.0

Terraform Configuration

resource "snowflake_database_role" "database_role" {
  database = "DB_TEST_DB_DEV"
  name     = "TEST_DATABASE_ROLE_02"
}

resource "snowflake_database_role" "parent_database_role" {
  database = "DB_TEST_DB_DEV"
  name     = "TEST_DATABASE_ROLE_01"
}

resource "snowflake_grant_database_role" "g" {
  database_role_name        = "\"DB_TEST_DB_DEV\".\"${snowflake_database_role.database_role.name}\""
  parent_database_role_name = "\"DB_TEST_DB_DEV\".\"${snowflake_database_role.parent_database_role.name}\""
}

Expected Behavior

Database role TEST_DATABASE_ROLE_02 granted to TEST_DATABASE_ROLE_01

Actual Behavior

panic: runtime error: index out of range [1] with length 1

goroutine 64 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadGrantDatabaseRole(0x14000878780, {0x1065e0960?, 0x14001016d00?})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_database_role.go:184 +0x668
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateGrantDatabaseRole(0x0?, {0x1065e0960?, 0x14001016d00})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_database_role.go:131 +0x758
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x106622bc8?, {0x106622bc8?, 0x14000a30990?}, 0xd?, {0x1065e0960?, 0x14001016d00?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:766 +0x134
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000b310a0, {0x106622bc8, 0x14000a30990}, 0x1400086eb60, 0x14000878600, {0x1065e0960, 0x14001016d00})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:909 +0x86c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140009fc648, {0x106622bc8?, 0x14000a307e0?}, 0x14000642f50)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xb08
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x106637bd8?, 0x140009fc648?}}, {0x106622bc8, 0x14000a307e0}, 0x0?)
	github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x58
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x106622c00?, {0x106622bc8?, 0x14000a304e0?}, 0x14000642f00)
	github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x184
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000bee000, {0x106622bc8?, 0x1400086bcb0?}, 0x140008724d0)
	github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x106592a40?, 0x14000bee000}, {0x106622bc8, 0x1400086bcb0}, 0x14000878380, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x164
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000cad20, {0x106622bc8, 0x1400086bc20}, {0x1066331e0, 0x14000102ea0}, 0x1400086d8c0, 0x14000bdf2c0, 0x1074aba78, 0x0)
	google.golang.org/grpc@v1.60.0/server.go:1372 +0xb8c
google.golang.org/grpc.(*Server).handleStream(0x140000cad20, {0x1066331e0, 0x14000102ea0}, 0x1400086d8c0)
	google.golang.org/grpc@v1.60.0/server.go:1783 +0xc4c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.60.0/server.go:1016 +0x5c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 52
	google.golang.org/grpc@v1.60.0/server.go:1027 +0x138

Error: The terraform-provider-snowflake_v0.84.0 plugin crashed!

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

2024-01-23T12:59:52.864Z [DEBUG] provider.terraform-provider-snowflake_v0.84.0: 2024/01/23 12:59:52 [DEBUG] sql-conn-exec: [query GRANT DATABASE ROLE "DB_TEST_DB_DEV"."TEST_DATABASE_ROLE_02" TO DATABASE ROLE "DB_TEST_DB_DEV"."TEST_DATABASE_ROLE_01" err <nil> duration 224.328125ms args {}] ()
2024-01-23T12:59:53.096Z [DEBUG] provider.terraform-provider-snowflake_v0.84.0: 2024/01/23 12:59:53 [DEBUG] sql-conn-query: [query SHOW GRANTS OF DATABASE ROLE "DB_TEST_DB_DEV"."TEST_DATABASE_ROLE_02" err <nil> duration 231.756667ms args {}] ()
2024-01-23T12:59:53.099Z [DEBUG] provider.terraform-provider-snowflake_v0.84.0: panic: runtime error: index out of range [1] with length 1
@adrianhicken adrianhicken added the bug Used to mark issues with provider's incorrect behavior label Jan 23, 2024
@sysadmin-exe
Copy link

sysadmin-exe commented Jan 23, 2024

Same with the latest 0.84.1 as well as 0.83.1.

@sfc-gh-asawicki
Copy link
Collaborator

Hey @adrianhicken. Thanks for reporting the issue.

As this is a new resource we will analyze it shortly.

@monti-python
Copy link

monti-python commented Feb 13, 2024

Same issue with the latest version 0.85.0
Any updates on this one @sfc-gh-asawicki? It's quite an important bug since database roles are useless if not granted to other roles.

Update: it fails with grants to another database role, i.e. when using parent_database_role_name. Grants to account roles using parent_role_name work as expected

@davidlee-ca
Copy link
Contributor

+1 on this - using 0.85.0, still crashing the same way.

@sfc-gh-jcieslak sfc-gh-jcieslak self-assigned this Feb 15, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hi all, I'm currently working on it. The fix should be merged and released soon as a bugfix version or next week as a regular minor release.

sfc-gh-asawicki pushed a commit that referenced this issue Feb 16, 2024
sfc-gh-jcieslak pushed a commit that referenced this issue Feb 28, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.87.0](v0.86.0...v0.87.0)
(2024-02-28)


### 🎉 **What's new:**

* Add network rule to the sdk
([#2526](#2526))
([b379565](b379565))
* supports collation of table column
([#2496](#2496))
([56771f1](56771f1))


### 🔧 **Misc**

* Clean up environment variables in tests and on CI
([#2543](#2543))
([9a10cb1](9a10cb1))
* replace warning in new grant resources with info log
([#2521](#2521))
([c3014b9](c3014b9))


### 🐛 **Bug fixes:**

* data retention days follow up
([#2566](#2566))
([7aba384](7aba384))
* data retention time parameters
([#2502](#2502))
([76abf21](76abf21))
* data retention time parameters follow-up
([#2530](#2530))
([5544544](5544544))
* Demote warning to info and set volatility for procedures and functions
([#2567](#2567))
([abaad7c](abaad7c)),
closes
[#2536](#2536)
* Fix ACCOUNT PARAMETERS option failover group resource
([#2522](#2522))
([61883f3](61883f3)),
closes
[#2517](#2517)
* Fix failover group alter syntax and suppression for pipe statement
([#2562](#2562))
([24d76c3](24d76c3))
* Fix few tests
([#2515](#2515))
([a523a6b](a523a6b))
* Fix provider config hierarchy
([#2551](#2551))
([677a12b](677a12b))
* Fix query_results in unsafe_execute resource
([#2512](#2512))
([94ca158](94ca158)),
closes
[#2491](#2491)
* Fix replication for database resource
([#2524](#2524))
([767fbce](767fbce)),
closes
[#2021](#2021)
* Fix show by id for external functions
([#2531](#2531))
([d910a84](d910a84)),
closes
[#2528](#2528)
* Fix various small problems
([#2552](#2552))
([f558ce6](f558ce6))
* Granting database roles
([#2511](#2511))
([dc27d64](dc27d64)),
closes
[#2402](#2402)
* grants on external volumes
([#2538](#2538))
([1de9a29](1de9a29))
* Handle old reference for table_id in table constraint resource
([#2558](#2558))
([d1e8912](d1e8912)),
closes
[#2535](#2535)
* loosen identifier field validation for account object identifiers
([#2564](#2564))
([a5ed8cd](a5ed8cd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @adrianhicken. We have released the fix as part of v0.87.0 release. Please follow the migration guide during the update. Please confirm that the issue is resolved in the newest version. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
6 participants