inwx / terraform-provider-inwx

INWX Terraform Provider plugin for Terraform
MIT License
19 stars 5 forks source link

[BUG] crash while trying to import inwx_domain_record #32

Closed kingcrunch closed 3 weeks ago

kingcrunch commented 1 month ago

Checklist

Describe the bug

Tried to import contact information. Plugin crashes

To Reproduce Steps to reproduce the behavior:

  1. Lookup domain contacts ID in web ui
  2. Add snippet (see below)
  3. terraform plan

Expected behavior no crash

Screenshots

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

Stack trace from the terraform-provider-inwx_v1.4.1 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 86 [running]:
github.com/inwx/terraform-provider-inwx/inwx/internal/resource.resourceContactRead({0xd13228, 0xc0005a6850}, 0xc0005a5d00, {0xb62340?, 0xc000514690})
    github.com/inwx/terraform-provider-inwx/inwx/internal/resource/resource_domain_contact.go:246 +0x76d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0000fa8c0, {0xd13180, 0xc0002e4ae0}, 0xd?, {0xb62340, 0xc000514690})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:725 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000fa8c0, {0xd13180, 0xc0002e4ae0}, 0xc0002ea270, {0xb62340, 0xc000514690})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:1016 +0x4a5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0002d5b18, {0xd131b8?, 0xc00058c640?}, 0xc0004c4540)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/grpc_provider.go:613 +0x48a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0001a26e0, {0xd13180?, 0xc0002e41e0?}, 0xc00007ca20)
    github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/tf5server/server.go:746 +0x418
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xbc8740?, 0xc0001a26e0}, {0xd13180, 0xc0002e41e0}, 0xc00007c240, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002228c0, {0xd16eb0, 0xc00040a1a0}, 0xc0005aa120, 0xc0002fa180, 0x11d56d0, 0x0)
    google.golang.org/grpc@v1.45.0/server.go:1282 +0xcd5
google.golang.org/grpc.(*Server).handleStream(0xc0002228c0, {0xd16eb0, 0xc00040a1a0}, 0xc0005aa120, 0x0)
    google.golang.org/grpc@v1.45.0/server.go:1619 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.45.0/server.go:921 +0x8d
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 20
    google.golang.org/grpc@v1.45.0/server.go:919 +0x246

Error: The terraform-provider-inwx_v1.4.1 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.

Additional context Add any other context about the problem here.

Sample .tf configuration:

terraform {
  required_providers {
    inwx = {
      source = "inwx/inwx"
      version = "~> 1.4"
    }
  }
}

provider "inwx" {
  username = "<redacted>"
  password = "<redacted>"
}

# Does not work with specific value neither
resource "inwx_domain_contact" "me" {
  city           = ""
  country_code   = ""
  email          = ""
  name           = ""
  phone_number   = ""
  postal_code    = ""
  street_address = ""
  type           = ""
}

import {
  # Tried both 123 and "123" (in quotes)
  id = <redacted>
  to = inwx_domain_contact.me
}
kingcrunch commented 1 month ago

So, with try-and-error I found out, that this is related to the TAN-authentification. While inwx_domain gives you a reasonable error message (something around "you need a tan") inwx_domain_contact just crashes with the message above