Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
511 stars 402 forks source link

[Bug]: Error: The terraform-provider-snowflake_v0.89.0 plugin crashed! #2779

Open Ghaitharar opened 2 months ago

Ghaitharar commented 2 months ago

Terraform CLI Version

0.89.0

Terraform Provider Version

0.89.0

Terraform Configuration

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

panic: interface conversion: sdk.ObjectIdentifier is sdk.AccountObjectIdentifier, not sdk.DatabaseObjectIdentifier

goroutine 77 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadSchema(0xc000b26880, {0x1cd55c0?, 0xc00008a778?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/schema.go:108 +0x899
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x24556c8?, {0x24556c8?, 0xc000b4f920?}, 0xd?, {0x1cd55c0?, 0xc00008a778?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:783 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a809a0, {0x24556c8, 0xc000b4f920}, 0xc000a8f1e0, {0x1cd55c0, 0xc00008a778})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0007df650, {0x24556c8?, 0xc000c06240?}, 0xc000d06c80)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:663 +0x48a
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x246b560?, 0xc0007df650?}}, {0x24556c8?, 0xc000c06240?}, 0xc001187380?)
github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:176 +0x225
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x2455700?, {0x24556c8?, 0xc000883e60?}, 0xc001187380)
github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0007fcbe0, {0x24556c8?, 0xc000883680?}, 0xc0011a4ae0)
github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:787 +0x48b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x20288a0?, 0xc0007fcbe0}, {0x24556c8, 0xc000883680}, 0xc000737800, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000e8d20, {0x24556c8, 0xc0008835f0}, {0x24667e0, 0xc000b84340}, 0xc000a437a0, 0xc000b154d0, 0x345f028, 0x0)
google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0000e8d20, {0x24667e0, 0xc000b84340}, 0xc000a437a0)
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 42
google.golang.org/grpc@v1.60.0/server.go:1027 +0x115
panic: interface conversion: sdk.ObjectIdentifier is sdk.AccountObjectIdentifier, not sdk.DatabaseObjectIdentifier

goroutine 76 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadSchema(0xc000cce180, {0x1cd55c0?, 0xc00008a778?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/schema.go:108 +0x899
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x24556c8?, {0x24556c8?, 0xc000c904b0?}, 0xd?, {0x1cd55c0?, 0xc00008a778?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:783 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a809a0, {0x24556c8, 0xc000c904b0}, 0xc000cae340, {0x1cd55c0, 0xc00008a778})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0007df650, {0x24556c8?, 0xc000c90360?}, 0xc000a261c0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:663 +0x48a
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x246b560?, 0xc0007df650?}}, {0x24556c8?, 0xc000c90360?}, 0xc000a26000?)
github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:176 +0x225
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x2455700?, {0x24556c8?, 0xc000c90060?}, 0xc000a26000)
github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0007fcbe0, {0x24556c8?, 0xc000f21770?}, 0xc000bd0780)
github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:787 +0x48b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x20288a0?, 0xc0007fcbe0}, {0x24556c8, 0xc000f21770}, 0xc000057100, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000e8d20, {0x24556c8, 0xc000f216e0}, {0x24667e0, 0xc000b84340}, 0xc000a43680, 0xc000b154d0, 0x345f028, 0x0)
google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0000e8d20, {0x24667e0, 0xc000b84340}, 0xc000a43680)
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 42
google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

Error: The terraform-provider-snowflake_v0.89.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.

Category

category:import

Object type(s)

No response

Expected Behavior

plan and apply with no issues.

Actual Behavior

The plugin crushed.

Steps to Reproduce

variable "DEV_schema_map" { description = "List of GEs" type = map default = { for SC in ["DE_1", "DE_2", "DE_3", "DE_4", "DE_5", "DE_6"] : SC => SC} }

resource "snowflake_schema" "DEV_schemas" { for_each = var.DEV_schema_map name = each.value database = snowflake_database.DEV.name }

import { for_each = var.DEV_schema_map id = each.value to = snowflake_schema.DEV_schemas[each.value] }

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

No response

Would you like to implement a fix?

sfc-gh-asawicki commented 2 months ago

Hey @Ghaitharar. Thanks for reaching out to us.

Your import statement is incorrect: https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/schema#import. You have to use qualified name and you are only using the schema name without the db.

sfc-gh-asawicki commented 2 weeks ago

Hey @Ghaitharar. Can you confirm that the proposed solution worked?