jeremmfr / terraform-provider-junos

Terraform provider for Junos devices
https://registry.terraform.io/providers/jeremmfr/junos
MIT License
62 stars 22 forks source link

Bug: #531

Closed computeracer closed 1 year ago

computeracer commented 1 year ago

Terraform and Provider Versions

terraform version 1.5.3 plugin version 2.1.0

terraform plan

terraform apply
...
Stack trace from the terraform-provider-junos_v2.1.0 plugin:

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

goroutine 705 [running]:
github.com/jeremmfr/terraform-provider-junos/internal/providerfwk.(*policyoptionsPolicyStatementBlockThen).isEmpty(0x0)
        github.com/jeremmfr/terraform-provider-junos/internal/providerfwk/resource_policyoptions_policy_statement.go:1318 +0x1d
github.com/jeremmfr/terraform-provider-junos/internal/providerfwk.(*policyoptionsPolicyStatementData).set(0xc0002381c0, {0x0?, 0x0?}, 0x15d9b60?)
        github.com/jeremmfr/terraform-provider-junos/internal/providerfwk/resource_policyoptions_policy_statement.go:2176 +0x1305
github.com/jeremmfr/terraform-provider-junos/internal/providerfwk.defaultResourceCreate({0x15d9b60, 0xc00114a150}, {0x15d5eb8, 0xc001218038}, 0xc001842e20, 0xc001842e00, {0x15d5ee0?, 0xc0002381c0}, 0xc000a017c0)
        github.com/jeremmfr/terraform-provider-junos/internal/providerfwk/default_resource_op.go:82 +0x254
github.com/jeremmfr/terraform-provider-junos/internal/providerfwk.(*policyoptionsPolicyStatement).Create(0xc001218038, {0x15d9b60, 0xc00114a150}, {{{{0x15df168, 0xc0018061b0}, {0x121c800, 0xc001593d10}}, {0x15e0f40, 0xc0011e6eb0}}, {{{0x15df168, ...}, ...}, ...}, ...}, ...)
        github.com/jeremmfr/terraform-provider-junos/internal/providerfwk/resource_policyoptions_policy_statement.go:1952 +0x2cf
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0xc0002034a0, {0x15d9b60, 0xc00114a150}, 0xc001843288, 0xc001843228)
        github.com/hashicorp/terraform-plugin-framework@v1.3.3/internal/fwserver/server_createresource.go:101 +0x598
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0xc000b913e0?, {0x15d9b60, 0xc00114a150}, 0xc001b019a0, 0xc0018433e0)
        github.com/hashicorp/terraform-plugin-framework@v1.3.3/internal/fwserver/server_applyresourcechange.go:57 +0x4a8
github.com/hashicorp/terraform-plugin-framework/internal/proto5server.(*Server).ApplyResourceChange(0xc0002034a0, {0x15d9b60?, 0xc00114a000?}, 0xc001b01900)
        github.com/hashicorp/terraform-plugin-framework@v1.3.3/internal/proto5server/server_applyresourcechange.go:55 +0x41a
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc0004e8ae0, 0xc00090b940, 0xc0004e8b10, 0xc0004e8b40, {0xc0003fbb80, 0x2, 0x2}}, {0x15d9b60?, 0xc001127cb0?}, 0xc001b01900)
        github.com/hashicorp/terraform-plugin-mux@v0.11.2/tf5muxserver/mux_server_ApplyResourceChange.go:30 +0x139
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00040e140, {0x15d9b60?, 0xc0011274a0?}, 0xc0004f20e0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x12f3b40?, 0xc00040e140}, {0x15d9b60, 0xc0011274a0}, 0xc0004f2070, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00011c000, {0x15df4b8, 0xc0001849c0}, 0xc001112900, 0xc00022ea20, 0x1c8f000, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc00011c000, {0x15df4b8, 0xc0001849c0}, 0xc001112900, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1714 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.1/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.1/server.go:957 +0x18c

Error: The terraform-provider-junos_v2.1.0 plugin crashed!

Terraform Configuration Files

resource "junos_policyoptions_policy_statement" "my_policy_statement" {
  name = "my_policy_statement"
  from {
    protocol = ["bgp"]
  }
  term {
    name = "term_1"
    from {
      route_filter {
        route  = "192.168.0.0/24"
        option = "exact"
      }
    }
    then {
      action = "accept"
    }
  }
  term {
    name = "term_2"
    then {
      action = "reject"
    }
  }
}

Expected Behavior

Both plan and apply runs successfully.

Actual Behavior

The plan runs successfully, but the apply crashes. 1.33 didnt crash, but 2.1.0 does.

Steps to Reproduce

  1. terraform plan
  2. terraform apply
jeremmfr commented 1 year ago

Hi 👋 , Sorry for the trouble here, this issue was already reported in #528 and fixed in v2.1.1 yesterday.