gerardlemetayerc / terraform-provider-device42

MIT License
1 stars 1 forks source link

Device - Refresh - panic: interface conversion: interface {} is nil, not string #65

Closed gerardlemetayerc closed 6 months ago

gerardlemetayerc commented 6 months ago

When executing refresh, got the following issue (random)

goroutine 31 [running]:
github.com/go-resty/resty/v2.responseLogger(0xc00027a000, 0xc000546000)
        /home/runner/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/middleware.go:301 +0x75c
github.com/go-resty/resty/v2.(*Client).execute(0xc00027a000, 0xc00024ed00)
        /home/runner/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/client.go:972 +0xbda
github.com/go-resty/resty/v2.(*Request).Execute(0xc00024ed00, {0x91a6c4?, 0xc000258f58?}, {0xc000039038, 0x16})
        /home/runner/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/request.go:758 +0x5e9
github.com/go-resty/resty/v2.(*Request).Get(...)
        /home/runner/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/request.go:689
github.com/gerardlemetayerc/terraform-provider-device42/device42.resourceDevice42DeviceRead(0xc0004a2900, {0x913f00?, 0xc00027a000})
        /home/runner/work/terraform-provider-device42/terraform-provider-device42/device42/resource_virtual_machine.go:210 +0x38e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xa78520?, {0xa78520?, 0xc000159da0?}, 0xd?, {0x913f00?, 0xc00027a000?})
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:712 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00037e1c0, {0xa78520, 0xc000159da0}, 0xc00000cea0, {0x913f00, 0xc00027a000})
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000414c30, {0xa78520?, 0xc000159c80?}, 0xc000265640)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0000003c0, {0xa78520?, 0xc0001594a0?}, 0xc000078fc0)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x8ee4c0?, 0xc0000003c0}, {0xa78520, 0xc0001594a0}, 0xc000330af0, 0x0)
        /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00042c000, {0xa7c0e0, 0xc00029c1a0}, 0xc0001638c0, 0xc000426cf0, 0xf482f0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.1/server.go:1358 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc00042c000, {0xa7c0e0, 0xc00029c1a0}, 0xc0001638c0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.1/server.go:1735 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.1/server.go:970 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.57.1/server.go:981 +0x15c

Error: The terraform-provider-device42_1.3.9_windows_amd64.exe plugin crashed!

Probably linked with following line : https://github.com/gerardlemetayerc/terraform-provider-device42/blob/main/device42/resource_virtual_machine.go#L210. Diagnostic had to be done (suspected incorrect answer from API side).

gerardlemetayerc commented 6 months ago

Add debug info on resourceDevice42DeviceRead to diagnose issue.

gerardlemetayerc commented 6 months ago

Following actions were took :

gerardlemetayerc commented 6 months ago

Looks like issue is linked to "debug" mode from resty client. When debug is disable, issue is not occuring anymore. Removing lines from code with debug mode to prevent issue (and will check is issue still producing).

gerardlemetayerc commented 6 months ago

Looks like it's ok now. Closing issue.