Getting an netbox_available_ip_address from a prefix that is 100% utilized results in a panic instead of a graceful error message.
Tested with both 3.1.0 (unsupported, I know) and 3.0.9 to make sure it's not an API thing. Happens with both.
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Stack trace from the terraform-provider-netbox_v1.0.2 plugin:
panic: runtime error: index out of range [0] with length 0
goroutine 45 [running]:
github.com/e-breuninger/terraform-provider-netbox/netbox.resourceNetboxAvailableIPAddressCreate(0x0, {0x11f49a0, 0xc00013a630})
github.com/e-breuninger/terraform-provider-netbox/netbox/resource_netbox_available_ip_address.go:87 +0x485
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x12164c0, {0x15e7598, 0xc00004eac0}, 0x2, {0x11f49a0, 0xc00013a630})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:329 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0005f4000, {0x15e7598, 0xc00004eac0}, 0xc0002d85b0, 0xc00039c080, {0x11f49a0, 0xc00013a630})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:467 +0x871
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000c0c0, {0x15e7598, 0xc00004eac0}, 0xc0002e4aa0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00057a900, {0x15e7640, 0xc000104300}, 0xc0001ee000)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:603 +0x30e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x13b3120, 0xc00057a900}, {0x15e7640, 0xc000104300}, 0xc0002a2960, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000523340, {0x15f6ad0, 0xc00019cc00}, 0xc000188000, 0xc000320f00, 0x2142f00, 0x0)
google.golang.org/[email protected]/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc000523340, {0x15f6ad0, 0xc00019cc00}, 0xc000188000, 0x0)
google.golang.org/[email protected]/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:857 +0x294
Error: The terraform-provider-netbox_v1.0.2 plugin crashed!
The provider should throw a human readable/understandable error message and not crash if prefix is full