Skip to content

Invalid device url will cause provider crash #252

@mike-krau

Description

@mike-krau

Explanation: In configuration I put a url without https://, and it caused it to crash on execution
for example the configuration i was trying was this.

iosxe: 
  devices: 
    - name: Device1 
      url: 10.122.20.79:2123
      configuration:
        system:
          hostname: test123

Notably, it should be:

iosxe: 
  devices: 
    - name: Device1 
      url: https://10.122.20.79:2123
      configuration:
        system:
          hostname: test123

Issue: The error I was receiving with this incorrect configuration is shown below. We should have a check that will provide clear debug output for this to prevent bad url input.

Error I received:
(.venv) mikey@mikey-VMware-Virtual-Platform:~/Desktop/terraform/terraform-example$ terraform apply
module.iosxe.terraform_data.validation: Refreshing state... [id=21d239be-aad9-a16e-6ba5-8c44ff7c7805]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

  • create

Terraform will perform the following actions:

module.iosxe.iosxe_system.system["Device1"] will be created

  • resource "iosxe_system" "system" {
    • device = "Device1"
    • hostname = "test123"
    • id = (known after apply)
    • ip_domain_name = "cisco.com"
    • ip_http_authentication_aaa_command_authorization = []
    • multicast_routing_vrfs = []
      }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

module.iosxe.iosxe_system.system["Device1"]: Creating...

│ Error: Request cancelled

│ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled.

Stack trace from the terraform-provider-iosxe_v0.5.10 plugin:

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

goroutine 16 [running]:
net/http.(*Request).SetBasicAuth(0x0, {0xc00003a0b7?, 0x1583887?}, {0xc00003a0ff?, 0xc000402200?})
net/http/request.go:1032 +0x7c
github.com/netascode/go-restconf.(*Client).NewReq(0xc0001cfa40, {0x1583887, 0x5}, {0xc0002e2ba0, 0x20}, {0x17cbd20, 0xc00005d420}, {0x0, 0x0, 0x0})
github.com/netascode/[email protected]/client.go:192 +0xd8
github.com/netascode/go-restconf.(*Client).PatchData(0xc0001cfa40, {0x159db03, 0x1a}, {0xc000344180, }, {, _, _})
github.com/netascode/[email protected]/client.go:555 +0x168
github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider.(*SystemResource).Create(0xc0000c4038, {0x17d4ba8, 0xc00050cf00}, {{{{0x17db4b0, 0xc00059cd20}, {0x143a620, 0xc00059c840}}, {0x17df9e8, 0xc0003a2140}}, {{{0x17db4b0, ...}, ...}, ...}, ...}, ...)
github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/resource_iosxe_system.go:301 +0x36f
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0xc0002cc008, {0x17d4ba8, 0xc00050cf00}, 0xc0002e3508, 0xc0002e34e0)
github.com/hashicorp/[email protected]/internal/fwserver/server_createresource.go:101 +0x578
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0xc0002cc008, {0x17d4ba8, 0xc00050cf00}, 0xc000540460, 0xc0002e35f8)
github.com/hashicorp/[email protected]/internal/fwserver/server_applyresourcechange.go:57 +0x4aa
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0xc0002cc008, {0x17d4ba8?, 0xc00050ce10?}, 0xc0005403c0)
github.com/hashicorp/[email protected]/internal/proto6server/server_applyresourcechange.go:55 +0x38e
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc0001ce960, {0x17d4ba8?, 0xc00050c1e0?}, 0xc000404230)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:866 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1553c40, 0xc0001ce960}, {0x17d4ba8, 0xc00050c1e0}, 0xc000478000, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:611 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00011e800, {0x17d4ba8, 0xc00050c150}, 0xc000418060, 0xc0002c8630, 0x1eb0358, 0x0)
google.golang.org/[email protected]/server.go:1405 +0x103b
google.golang.org/grpc.(*Server).handleStream(0xc00011e800, {0x17d5598, 0xc00042c000}, 0xc000418060)
google.golang.org/[email protected]/server.go:1815 +0xbaa
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/[email protected]/server.go:1035 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 20
google.golang.org/[email protected]/server.go:1046 +0x125

Error: The terraform-provider-iosxe_v0.5.10 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions