F5Networks / terraform-provider-bigip

Terraform resources that can configure F5 BIG-IP products
https://registry.terraform.io/providers/F5Networks/bigip/latest/docs
Mozilla Public License 2.0
104 stars 119 forks source link

bigip.resourceBigipSslCertificateRead error checking is wrong #812

Closed marsom closed 1 year ago

marsom commented 1 year ago

Environment

Summary

golang wrong error handling, if you delte someting in the f5 gui an drun terrform it will crash

tack trace from the terraform-provider-bigip_v1.17.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x130 pc=0xa47937]

goroutine 129 [running]:
github.com/F5Networks/terraform-provider-bigip/bigip.resourceBigipSslCertificateRead({0xf8b800?, 0xc0004b5b90?}, 0xc000125480, {0xe16620?, 0xc0005e6700})
github.com/F5Networks/terraform-provider-bigip/bigip/resource_bigip_ssl_certificate.go:116 +0x357
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0004afea0, {0xf8b800, 0xc0004b5b90}, 0xd?, {0xe16620, 0xc0005e6700})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0004afea0, {0xf8b800, 0xc0004b5b90}, 0xc000918f70, {0xe16620, 0xc0005e6700})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000437fc8, {0xf8b800?, 0xc0004b5a70?}, 0xc000123340)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000250be0, {0xf8b800?, 0xc0004b5110?}, 0xc00021cc60)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xdd9500?, 0xc000250be0}, {0xf8b800, 0xc0004b5110}, 0xc0001818f0, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00024a1e0, {0xf8f3a0, 0xc00031d520}, 0xc00066c000, 0xc0004b4de0, 0x14f0f70, 0x0)
google.golang.org/grpc@v1.51.0/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc00024a1e0, {0xf8f3a0, 0xc00031d520}, 0xc00066c000, 0x0)
google.golang.org/grpc@v1.51.0/server.go:1713 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/grpc@v1.51.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.51.0/server.go:963 +0x28a

Error: The terraform-provider-bigip_v1.17.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.

the problem ish here

https://github.com/F5Networks/terraform-provider-bigip/blob/master/bigip/resource_bigip_ssl_key.go#L112

and probabliy in other locations too

the if err check must be after the

G-gonzalezjimenez commented 1 year ago

thank you for reporting this Bug, tracking internally with 1187

RavinderReddyF5 commented 1 year ago

Hi @marsom, is this issue reproducible on v1.18.0 ?