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.83.1 crashes on any execution (JWT) #2369

Closed
lastlee opened this issue Jan 18, 2024 · 4 comments · Fixed by #2421
Closed

Provider v0.83.1 crashes on any execution (JWT) #2369

lastlee opened this issue Jan 18, 2024 · 4 comments · Fixed by #2421
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@lastlee
Copy link
Contributor

lastlee commented Jan 18, 2024

Terraform CLI and Provider Versions

Terraform v1.5.7

Terraform Configuration

resource "snowflake_account_grant" "oaccount_support_case_grant" {
  roles = [
    snowflake_role.admin.name,
    snowflake_role.all_tables_views_readonly.name,
    snowflake_role.non_customer_data_tables_views_readonly.name,
  ]
  privilege         = "MANAGE ACCOUNT SUPPORT CASES"
  with_grant_option = false
}

resource "snowflake_account_parameter" "allow_id_token" {
  key   = "ALLOW_ID_TOKEN"
  value = "true"
}
...
provider "snowflake" {
  user                   = var.sfc_username
  account                = var.sfc_account
  private_key            = file(var.sfc_private_key_path)
  private_key_passphrase = var.sfc_private_key_passphrase
  authenticator          = "JWT"
  role                   = "ACCOUNTADMIN"
  warehouse              = var.warehouse_name
}
...
terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "~> 0.83.1"
    }
  }
}

Expected Behavior

Provider should successfully deploy the resources

Actual Behavior

│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.

│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-snowflake_v0.83.1 plugin:

panic: interface conversion: interface {} is nil, not bool

goroutine 422 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.UpdateDatabase(0xc001693680, {0x1fc48c0?, 0xc0009acf70})
        github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/database.go:297 +0x1885
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x234a7a8?, {0x234a7a8?, 0xc000bebb90?}, 0xd?, {0x1fc48c0?, 0xc0009acf70?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:800 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000798460, {0x234a7a8, 0xc000bebb90}, 0xc000b5ac30, 0xc001693500, {0x1fc48c0, 0xc0009acf70})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000a48798, {0x234a7a8?, 0xc000beb9e0?}, 0xc000b3af00)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xdbc
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x235fdc0?, 0xc000a48798?}}, {0x234a7a8, 0xc000beb9e0}, 0x0?)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x234a7e0?, {0x234a7a8?, 0xc000beb6e0?}, 0xc000b3aeb0)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000a46780, {0x234a7a8?, 0xc000beaed0?}, 0xc001395b20)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1f76820?, 0xc000a46780}, {0x234a7a8, 0xc000beaed0}, 0xc001693080, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00014cd20, {0x234a7a8, 0xc000beae40}, {0x235b0c0, 0xc000682340}, 0xc000d8fd40, 0xc0008e00c0, 0x330db58, 0x0)
        google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc00014cd20, {0x235b0c0, 0xc000682340}, 0xc000d8fd40)
        google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.0/server.go:1016 +0x59
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 26
        google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

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

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

Targeted applies also fail for individual resources

@lastlee lastlee added the bug Used to mark issues with provider's incorrect behavior label Jan 18, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @lastlee. Thanks for reporting the issue.

It looks like there is a problem with your database resource, ignore_edition_check (part of replications) field in particular. Please share your database resources configs.

@lastlee
Copy link
Contributor Author

lastlee commented Jan 18, 2024

Interesting -- I think this does isolate the issue, however I am still having issues with the ignore_edition_check set to true.

  # module.sfc_reporting.snowflake_database.database_reporting_to_lake will be updated in-place
  ~ resource "snowflake_database" "database_reporting_to_lake" {
        id                          = "DATALAKE_SUBSCRIPTION"
        name                        = "DATALAKE_SUBSCRIPTION"
        # (3 unchanged attributes hidden)

      + replication_configuration {
          + accounts             = [
              + "<org>.DATALAKEDEMO1",
            ]
          + ignore_edition_check = true
        }
    }

and the provider still fails with the same/similar error and stacktrace:

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

goroutine 61 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.UpdateDatabase(0xc000ea2180, {0x1fc48c0?, 0xc00085d1e0})
        github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/database.go:271 +0x19d4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x234a7a8?, {0x234a7a8?, 0xc000e0b260?}, 0xd?, {0x1fc48c0?, 0xc00085d1e0?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:800 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0006faee0, {0x234a7a8, 0xc000e0b260}, 0xc00085c5b0, 0xc000c53f80, {0x1fc48c0, 0xc00085d1e0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000ab0558, {0x234a7a8?, 0xc000e0b0b0?}, 0xc000e1a410)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xdbc
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x235fdc0?, 0xc000ab0558?}}, {0x234a7a8, 0xc000e0b0b0}, 0x0?)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x234a7e0?, {0x234a7a8?, 0xc000e0adb0?}, 0xc000e1a3c0)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000ab43c0, {0x234a7a8?, 0xc000e0a390?}, 0xc000e5a000)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1f76820?, 0xc000ab43c0}, {0x234a7a8, 0xc000e0a390}, 0xc000c52e80, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000dcd20, {0x234a7a8, 0xc000e0a300}, {0x235b0c0, 0xc0006029c0}, 0xc000e56000, 0xc0002c47b0, 0x330db58, 0x0)
        google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0000dcd20, {0x235b0c0, 0xc0006029c0}, 0xc000e56000)
        google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.0/server.go:1016 +0x59
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
        google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

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

@sfc-gh-asawicki
Copy link
Collaborator

@lastlee, thanks for the logs. It looks like the casting issue when there was no previous config. It should be relatively easy to fix; we will check it in the next few days.

@joshcazalas
Copy link

+1 on this issue. I'm unable to apply anything Snowflake right now due to this same bug.

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


##
[0.85.0](v0.84.1...v0.85.0)
(2024-02-01)


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

* Add API integration to the SDK
([#2409](#2409))
([23acda5](23acda5))
* add application to sdk
([#2350](#2350))
([de97ad8](de97ad8))
* add external funcs to sdk
([#2440](#2440))
([c8cf09b](c8cf09b))
* Add grant privileges to share resource
([#2447](#2447))
([d8241a5](d8241a5))
* Add materialized view to the SDK
([#2403](#2403))
([a5ce699](a5ce699))
* Add notification integration to the SDK
([#2412](#2412))
([d84240c](d84240c))
* add sequences to sdk
([#2351](#2351))
([d2e5ffd](d2e5ffd))
* add snowflake grant privileges to account role
([#2365](#2365))
([e3d086e](e3d086e))
* add streamlits to sdk
([#2400](#2400))
([129d24c](129d24c))
* add-call-with to sdk
([#2337](#2337))
([ebcd1bc](ebcd1bc))
* stages migration follow-up
([#2372](#2372))
([3939dbe](3939dbe))
* Use API integration from SDK
([#2429](#2429))
([1ccc864](1ccc864))
* Use managed account from the SDK
([#2420](#2420))
([3aaa080](3aaa080))
* Use materialized views and views from SDK
([#2448](#2448))
([dc66d02](dc66d02))
* Use notification integration from sdk
([#2445](#2445))
([e8915cc](e8915cc))
* use roles from the SDK
([#2405](#2405))
([c645b4d](c645b4d))
* Use row access policy from SDK
([#2428](#2428))
([119af5e](119af5e))
* Use SDK in the storage integration
([#2380](#2380))
([ce0741c](ce0741c))
* use sequence from sdk and add ordering attr
([#2419](#2419))
([973b8f7](973b8f7)),
closes
[#2387](#2387)
* Use stage from sdk
([#2427](#2427))
([c17effd](c17effd))


### 🔧 **Misc**

* add missing deprecation message
([#2451](#2451))
([77de569](77de569))


### 🐛 **Bug fixes:**

* account role test
([#2422](#2422))
([c1b47d1](c1b47d1))
* Adjust tests after Snowflake behavior change
([#2404](#2404))
([8c03ffb](8c03ffb))
* app-pkg unset
([#2399](#2399))
([fedb1df](fedb1df))
* Fix some bugs
([#2421](#2421))
([dec7cd9](dec7cd9)),
closes
[#2358](#2358)
[#2369](#2369)
[#2329](#2329)
* snowflake_grant_privileges_to_role read
([#2424](#2424))
([5385cec](5385cec))

---
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>
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
Development

Successfully merging a pull request may close this issue.

3 participants