Snowflake-Labs / terraform-provider-snowflake

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

[Bug]: The terraform-provider-snowflake_v0.91.0 plugin crashed! #2829

Open sfc-gh-swaswani opened 4 months ago

sfc-gh-swaswani commented 4 months ago

Terraform CLI Version

Yet to be confirmed

Terraform Provider Version

0.91.0

Terraform Configuration

Requested with customer

Category

category:import

Object type(s)

resource:alert

Expected Behavior

The pipeline should run fine.

Actual Behavior

The customer is able to run the pipeline to test the codes, and it's running fine, but it fails to implement the changes from the feature branch to the dev environment.

Steps to Reproduce

Requested with customer

How much impact is this issue causing?

High

Logs

No response

Additional Information

The customer is experiencing a crash with the terraform-provider-snowflake_v0.91.0 plugin during their pipeline. The pipeline fails after a merge request is approved and the feature branch changes are implemented into the dev environment, although the pipeline runs successfully during testing.

Error: Request cancelled │ │ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled. ╵ 

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

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

goroutine 85 [running]: 

github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.getAlertSchedule({0x1ccb900?, 0xc0008ae6c0?}) 
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/alert.go:254 +0x2ef 
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateAlert({0x242f060, 0xc001379b90}, 0x0?, {0x1ca4ec0?, 0xc000b845b8?}) 
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/alert.go:215 +0x20b 
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0000b2b60, {0x242efb8, 0xc000bd20f0}, 0xd?, {0x1ca4ec0, 0xc000b845b8}) 
github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:778 +0x11b 
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0000b2b60, {0x242efb8, 0xc000bd20f0}, 0xc0012d1ad0, 0xc001364980, {0x1ca4ec0, 0xc000b845b8}) 
github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:909 +0xa89 
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00079c8d0, {0x242efb8?, 0xc000a8ff20?}, 0xc000b999f0) 
github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xdbc 
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x2445c40?, 0xc00079c8d0?}}, {0x242efb8, 0xc000a8ff20}, 0x0?) 
github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf5to6server/tf5to6server.go:47 +0x54 
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x242eff0?, {0x242efb8?, 0xc000a8fc20?}, 0xc000b999a0) 
github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193 
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc0007bca00, {0x242efb8?, 0xc000b96150?}, 0xc0013b2d90) 
github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/tf6server/server.go:846 +0x3d0 
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1ffb1e0?, 0xc0007bca00}, {0x242efb8, 0xc000b96150}, 0xc0008ead00, 0x0) 
github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:518 +0x169 
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00096aa00, {0x242efb8, 0xc000b960c0}, {0x2440e00, 0xc000018300}, 0xc0011b0ea0, 0xc000b2c8d0, 0x33d3978, 0x0) 
google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23 
google.golang.org/grpc.(*Server).handleStream(0xc00096aa00, {0x2440e00, 0xc000018300}, 0xc0011b0ea0) 
google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016 
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 9 
google.golang.org/grpc@v1.63.2/server.go:1030 +0x135 

Error: The terraform-provider-snowflake_v0.91.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. Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit code 1

Would you like to implement a fix?

sfc-gh-jcieslak commented 4 months ago

As discussed the workaround for now is to set the "alert_schedule" field. I'll add this issue to our list of bugfixes to resolve during alert resource refactor (here).