devopsarr / terraform-provider-radarr

Terraform Radarr provider
https://registry.terraform.io/providers/devopsarr/radarr
Mozilla Public License 2.0
11 stars 0 forks source link

Plugin failure #205

Closed mscreations closed 1 year ago

mscreations commented 1 year ago

I am encountering an error when I try to setup an email notification. In my terraform file, I have this resource block:

resource "radarr_notification_email" "radarr" {
  on_grab = false
  on_download = false
  on_upgrade = false
  on_movie_added = false
  on_movie_delete = true
  on_movie_file_delete = true
  on_movie_file_delete_for_upgrade = false
  on_health_issue = true
  on_application_update = true

  include_health_warnings = true
  name = "Gmail"
  server = "smtp.gmail.com"
  port = 587
  require_encryption = true
  username = data.sops_file.secrets.data["smtp_user"]
  password = data.sops_file.secrets.data["smtp_pass"]
  from = data.sops_file.secrets.data["smtp_from"]
  to = ["${var.notification_email}"]
}

When I run terraform apply I get the following error:

╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The
│ plugin logs may contain more details.
╵

Stack trace from the terraform-provider-radarr_v1.8.0 plugin:

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

goroutine 10 [running]:
github.com/hashicorp/terraform-plugin-framework/types/basetypes.SetValue.ToTerraformValue({{0x0, 0x0, 0x0}, {0x0, 0x0}, 0x0}, {0x10c6c80, 0xc0002d5a40})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/types/basetypes/set.go:385 +0xa1
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromAttributeValue({0x10c6c80, 0xc0002d5a40}, {0x10cb348?, 0xc00047e880?}, {0x10cb390?, 0xc0000fec60?}, {{0xc00047f300?, 0xc0007d4478?, 0x40d5bf?}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/interfaces.go:316 +0xdb
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromValue({0x10c6c80, 0xc0002d5a40}, {0x10cb348?, 0xc00047e880}, {0xee0180, 0xc0000fec60}, {{0xc00047f300?, 0xf3770c?, 0x16?}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/outof.go:23 +0xb75
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromStruct({0x10c6c80, 0xc0002d5a40}, {0x10cc588?, 0xc000785cb0?}, {0xf04000?, 0xc0000fec00?, 0xc0000fec00?}, {{0x16fc540, 0x0, 0x0}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/struct.go:171 +0x4cf
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromValue({0x10c6c80, 0xc0002d5a40}, {0x10cb2b8?, 0xc000785cb0}, {0xf04000, 0xc0000fec00}, {{0x16fc540?, 0x0?, 0xd32a33?}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/outof.go:54 +0x95b
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromPointer({0x10c6c80, 0xc0002d5a40}, {0x10cb2b8?, 0xc000785cb0?}, {0xe45b40?, 0xc0000fea80?, 0x120?}, {{0x16fc540, 0x0, 0x0}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/pointer.go:115 +0x205
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromValue({0x10c6c80, 0xc0002d5a40}, {0x10cb2b8?, 0xc000785cb0}, {0xe45b40, 0xc0000fea80}, {{0x16fc540?, 0xf25233?, 0x4?}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/outof.go:82 +0x6e5
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromPointer({0x10c6c80, 0xc0002d5a40}, {0x10cb2b8?, 0xc000785cb0?}, {0xd883e0?, 0xc00011c700?, 0x0?}, {{0x16fc540, 0x0, 0x0}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/pointer.go:115 +0x205
github.com/hashicorp/terraform-plugin-framework/internal/reflect.FromValue({0x10c6c80, 0xc0002d5a40}, {0x10cb2b8?, 0xc000785cb0}, {0xd883e0, 0xc00011c700}, {{0x16fc540?, 0x0?, 0x0?}})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/reflect/outof.go:82 +0x6e5
github.com/hashicorp/terraform-plugin-framework/internal/fwschemadata.(*Data).Set(0xc0007d4e30, {0x10c6c80, 0xc0002d5a40}, {0xd883e0, 0xc00011c700})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/fwschemadata/data_set.go:15 +0x9a
github.com/hashicorp/terraform-plugin-framework/tfsdk.(*State).Set(0xc000218d70, {0x10c6c80?, 0xc0002d5a40?}, {0xd883e0?, 0xc00011c700?})
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/tfsdk/state.go:60 +0x165
github.com/devopsarr/terraform-provider-radarr/internal/provider.(*NotificationEmailResource).Create(0xc00011c6d8, {0x10c6c80, 0xc0002d5a40}, {{{{0x10cc6e8, 0xc0003961e0}, {0xe05e20, 0xc00034c3f0}}, {0x10ce600, 0xc0000a7d10}}, {{{0x10cc6e8, ...}, ...}, ...}, ...}, ...)
        github.com/devopsarr/terraform-provider-radarr/internal/provider/notification_email_resource.go:272 +0x3d9
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0xc0002291e0, {0x10c6c80, 0xc0002d5a40}, 0xc0007d5360, 0xc0007d5300)
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/fwserver/server_createresource.go:97 +0x5b8
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0x10c6c80?, {0x10c6c80, 0xc0002d5a40}, 0xc00049a7d0, 0xc0007d54d0)
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/fwserver/server_applyresourcechange.go:54 +0x4a8
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0xc0002291e0, {0x10c6c80?, 0xc0002d58f0?}, 0xc00049a780)
        github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/proto6server/server_applyresourcechange.go:52 +0x27b
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000225040, {0x10c6c80?, 0xc0002d5110?}, 0xc000226540)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov6/tf6server/server.go:816 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xedefa0?, 0xc000225040}, {0x10c6c80, 0xc0002d5110}, 0xc0002264d0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00029a1e0, {0x10ccbb8, 0xc0002ad6c0}, 0xc000728ea0, 0xc00041a030, 0x16be6c0, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc00029a1e0, {0x10ccbb8, 0xc0002ad6c0}, 0xc000728ea0, 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-radarr_v1.8.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.

If I try to run terraform apply a 2nd time, I receive an error because the email notification was created the first time, but terraform doesn't know that from the previous error. The plugin worked normally to create all other resource blocks; only this one has an issue.

mscreations commented 1 year ago

Some more information that may be useful:

Radarr: Version 4.6.4.7568 Package Version 4.6.4.7568-ls182 by linuxserver.io

Terraform v1.5.4 on linux_amd64

Fuochi commented 1 year ago

Hi @mscreations, It seems there is a problem on set creation. it may have been already solved here: https://github.com/devopsarr/terraform-provider-radarr/blob/44969496c3d3444d11a096a1a93453f7ee066c2e/internal/provider/notification_resource.go#L152 But I haven't released the new version yet. I'll try to have a look at this to confirm the behavior in the next couple of weeks. Thanks for reporting the issue!

Fuochi commented 1 year ago

Hi @mscreations, just to give you an update. I was able to replicate the issue with your settings. I confirm that it is already fixed on main, I'll wrap up few other things and prepare for the next release by the end of next week

Fuochi commented 1 year ago

Hi @mscreations, This should be now fixed in v2.0.0. Could you please check if it is? Be careful, there are few breaking changes in the new version.

mscreations commented 1 year ago

I have verified that this is fixed in v2.0.0. Thank you!