fivetran / terraform-provider-fivetran

Terraform Provider for Fivetran
https://fivetran.com
Apache License 2.0
40 stars 24 forks source link

bug: panic / crash during terraform plan #378

Open mnahkies opened 3 days ago

mnahkies commented 3 days ago

Describe the bug Encountering a panic from the provider when planning some of our workspaces. The terraform configuration for the fivetran provider resources hasn't changed recently, making me suspect that an API response has changed to cause this.

Appears to be related to this line https://github.com/fivetran/terraform-provider-fivetran/blob/v1.4.0/fivetran/framework/core/model/connector_schema_config.go#L256

To Reproduce Not sure yet.

Expected behavior No panic / crash.

Logs & Output

Stack trace from the terraform-provider-fivetran_v1.4.0 plugin:

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

goroutine 74 [running]:
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.(*ConnectorSchemaResourceModel).getSchemasMap(0xc0008feee0, {0xc000a573b0, 0x1, 0x6?})
        github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector_schema_config.go:256 +0x15a6
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.(*ConnectorSchemaResourceModel).ReadFromResponse(0xc0008feee0, {{{0xc00091d590, 0x7}, {0x0, 0x0}}, {{0xc000985780, 0xd}, 0xc000a0d9b0}}, 0xc00097e6c8)
        github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector_schema_config.go:87 +0x813
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources.(*connectorSchema).Read(0x411a7b?, {0xf0d6f8, 0xc0005d0630}, {{{{0xf12e50, 0xc0009a4ea0}, {0xc8ba20, 0xc00099a270}}, {0xf15700, 0xc000c42140}}, 0xc00011a438, ...}, ...)
        github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources/connector_schema_resource.go:352 +0x57b
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadResource(0xc000156ea0, {0xf0d6f8, 0xc0005d0630}, 0xc0005d0690, 0xc000ca96b0)
        github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/fwserver/server_readresource.go:101 +0x62e
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadResource(0xc000156ea0, {0xf0d6f8?, 0xc0005d0540?}, 0xc00069b840)
        github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/proto6server/server_readresource.go:55 +0x38e
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0000bdb80, {0xf0d6f8?, 0xc000c0e2a0?}, 0xc000701800)
        github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/tf6server/server.go:776 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0xd7f5c0, 0xc0000bdb80}, {0xf0d6f8, 0xc000c0e2a0}, 0xc00005d400, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000195000, {0xf0d6f8, 0xc000c0e180}, {0xf13d60, 0xc0001aa180}, 0xc0005c5560, 0xc000534540, 0x1528a68, 0x0)
        google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc000195000, {0xf13d60, 0xc0001aa180}, 0xc0005c5560)
        google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 40
        google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-fivetran_v1.4.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.

Operation failed: failed running terraform plan (exit 1)

Plugin version: Provider: 1.4.0 Terraform: 1.9.2

mnahkies commented 2 days ago

In order to solve, we've had to resort to removing the from state:

 terraform state rm 'module.some_resource_address.fivetran_connector_schema_config.schema'

Found that even removing the resources entirely from our config, terraform plan would crash rather than produce a plan to destroy them, leading us to conclude it was an issue with the state or it's interaction with what the server was returning during plan.

After removing from state terraform plan and terraform apply started working again.