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

Snowflake Provider v0.76.0 Plugin Crashing #2222

Closed
leo-mcn opened this issue Nov 29, 2023 · 6 comments
Closed

Snowflake Provider v0.76.0 Plugin Crashing #2222

leo-mcn opened this issue Nov 29, 2023 · 6 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@leo-mcn
Copy link

leo-mcn commented Nov 29, 2023

Terraform CLI and Provider Versions

Provider version v0.76.0

Terraform Configuration

provider "registry.terraform.io/snowflake-labs/snowflake" {
  version     = "0.76.0"
  constraints = "~> 0.73"

Expected Behavior

Expected for some changes to apply instead of the plugin breaking.

Actual Behavior

Error received below:


panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 90 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.getColumn({0x1a9c400?, 0xc0012ed650})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table.go:446 +0x4f7
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.getColumns({0x19d7a40?, 0xc000b60f48?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table.go:467 +0xb0
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.UpdateTable(0xc001426d00, {0x1ced480?, 0xc000c38820})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table.go:668 +0x6f1
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x2054060?, {0x2054060?, 0xc000a97680?}, 0xd?, {0x1ced480?, 0xc000c38820?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:800 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000993c00, {0x2054060, 0xc000a97680}, 0xc000ce5930, 0xc001217100, {0x1ced480, 0xc000c38820})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:919 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0009da930, {0x2054060?, 0xc000a974a0?}, 0xc0006df5e0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1060 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x2073560?, 0xc0009da930?}}, {0x2054060, 0xc000a974a0}, 0x0?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:37 +0x5a
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x2053fb8?, {0x2054060?, 0xc000a97170?}, 0xc0006df590)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc0009cb9a0, {0x2054060?, 0xc000a96960?}, 0xc001396850)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:857 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1c998c0?, 0xc0009cb9a0}, {0x2054060, 0xc000a96960}, 0xc0013967e0, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00023f4a0, {0x2063ec0, 0xc0009deea0}, 0xc0010f1200, 0xc000231230, 0x2d7e8d8, 0x0)
google.golang.org/[email protected]/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc00023f4a0, {0x2063ec0, 0xc0009deea0}, 0xc0010f1200, 0x0)
google.golang.org/[email protected]/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:996 +0x18c

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

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

@leo-mcn leo-mcn added the bug Used to mark issues with provider's incorrect behavior label Nov 29, 2023
@sfc-gh-asawicki
Copy link
Collaborator

Hey @leo-mcn. Thanks for creating the issue.

Please provide the config you use (ideally, the simplified one showing the issue).

The other info is that we are migrating tables to the new SDK, which may be enough to fix the issue.

@messi198310
Copy link

I have just had a crash with the same plugin updating grants on Snowpipes,Functions and file formats from the old method to the new snowflake_grant_privileges_to_role resource

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

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

goroutine 71 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewSchemaObjectIdentifierFromFullyQualifiedName({0xc0009ed458?, 0xc000c893e0?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/identifier_helpers.go:206 +0x46a
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.configureAccountRoleGrantPrivilegeOptions(0xc000c9a2e0?, {0xc000c8f330, 0x1, 0x1}, 0x1?, 0xc000b56cf0)
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_privileges_to_role.go:746 +0xd85
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateGrantPrivilegesToRole(0x0?, {0x1ced480?, 0xc0009211e0?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_privileges_to_role.go:456 +0x1ad
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x2054060?, {0x2054060?, 0xc000b3ce10?}, 0xd?, {0x1ced480?, 0xc0009211e0?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:766 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0000dee00, {0x2054060, 0xc000b3ce10}, 0xc000b5c820, 0xc000711080, {0x1ced480, 0xc0009211e0})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:909 +0xa7e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0007499f8, {0x2054060?, 0xc000b3cc30?}, 0xc000b09d60)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1060 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x2073560?, 0xc0007499f8?}}, {0x2054060, 0xc000b3cc30}, 0x0?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:37 +0x5a
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x2053fb8?, {0x2054060?, 0xc000b3c900?}, 0xc000b09d10)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc0007a0640, {0x2054060?, 0xc000ad9920?}, 0xc000b94cb0)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:857 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1c998c0?, 0xc0007a0640}, {0x2054060, 0xc000ad9920}, 0xc000b94c40, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0005632c0, {0x2063ec0, 0xc0009a04e0}, 0xc000b00b40, 0xc000778d80, 0x2d7e8d8, 0x0)
google.golang.org/[email protected]/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc0005632c0, {0x2063ec0, 0xc0009a04e0}, 0xc000b00b40, 0x0)
google.golang.org/[email protected]/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:996 +0x18c

@messi198310
Copy link

I think its related to this

Error: error granting privileges to account role: 003111 (0A000): SQL compilation error:
Bulk grant on objects of type PIPE to ROLE is restricted.

resource "snowflake_grant_privileges_to_role" "snowpipe_grants" {
provider = snowflake.security_admin
privileges = ["OPERATE"]
role_name = var.roles["raw_admin"].name
on_schema_object {
all {
object_type_plural = "PIPES"
in_schema = ""${snowflake_database.dw_db.name}"."${var.schemas.raw_dynamodb.name}""
}
}
}

@messi198310
Copy link

Tried with individual grants for the snowpipes and it still breaks with the below stack trace

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

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

goroutine 71 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewSchemaObjectIdentifierFromFullyQualifiedName({0xc000d42288?, 0xc000d53170?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/identifier_helpers.go:206 +0x46a
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.configureAccountRoleGrantPrivilegeOptions(0xc000d58740?, {0xc000d5ced0, 0x1, 0x1}, 0x1?, 0xc000d1acf0)
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_privileges_to_role.go:746 +0xd85
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateGrantPrivilegesToRole(0x0?, {0x1ced480?, 0xc0008cf860?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/grant_privileges_to_role.go:456 +0x1ad
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x2054060?, {0x2054060?, 0xc000d44ba0?}, 0xd?, {0x1ced480?, 0xc0008cf860?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:766 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0009c89a0, {0x2054060, 0xc000d44ba0}, 0xc000d29450, 0xc000707580, {0x1ced480, 0xc0008cf860})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:909 +0xa7e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0009be048, {0x2054060?, 0xc000d449c0?}, 0xc000d480a0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1060 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x2073560?, 0xc0009be048?}}, {0x2054060, 0xc000d449c0}, 0x0?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:37 +0x5a
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x2053fb8?, {0x2054060?, 0xc000d44690?}, 0xc000d48050)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc0008e0500, {0x2054060?, 0xc000d23e60?}, 0xc000ceb260)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:857 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1c998c0?, 0xc0008e0500}, {0x2054060, 0xc000d23e60}, 0xc000ceb1f0, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000992c0, {0x2063ec0, 0xc00043c340}, 0xc000c950e0, 0xc00062a2a0, 0x2d7e8d8, 0x0)
google.golang.org/[email protected]/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc0000992c0, {0x2063ec0, 0xc00043c340}, 0xc000c950e0, 0x0)
google.golang.org/[email protected]/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:996 +0x18c

@ric-sylvera
Copy link

I work with @leo-mcn and have been digging around. This is an issue in how we define our columns in an internal module:

  dynamic "column" {
    for_each = each.value["columns"]

    content {
      name     = upper(column.key)
      type     = column.value["type"]
      nullable = column.value["nullable"]
      comment  = column.value["comment"]
      default {
        expression = column.value["default"]
      }
    }
  }

So here, the default block value expression can be set to null, which caused the type assertion at github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/table.go:446 to fail.

This was fixed by making the default block conditional:

  dynamic "column" {
    for_each = each.value["columns"]

    content {
      name     = upper(column.key)
      type     = column.value["type"]
      nullable = column.value["nullable"]
      comment  = column.value["comment"]

      dynamic "default" {
        for_each = column.value["default"] == null ? [] : [column.value["default"]]
        content {
          expression = default.value
        }
      }
    }

@leo-mcn leo-mcn closed this as completed Nov 29, 2023
@sfc-gh-asawicki
Copy link
Collaborator

@messi198310 you have a problem with the identifiers (using unqualified where the qualified one is expected). Please try to update the config and if this does not help create a separate issue with config provided.

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

No branches or pull requests

4 participants