Skip to content

Provide descriptive error message when base_url is incorrectly set or unavailable #107

@brianshurley-esource

Description

@brianshurley-esource

Using this simple example:

provider "cloudconnexa" {
  base_url = "https://[company_name].api.openvpn.com"
  client_id     = "REDACTED"
  client_secret = "REDACTED"
}

terraform {
  required_providers {
    cloudconnexa = {
      source  = "OpenVPN/cloudconnexa"
      version = "= 1.0.1"
    }
  }
}

resource "cloudconnexa_network" "this" {
  description     = "OpenTofu test network"
  egress          = true
  name            = "opentofu_test_network"
  internet_access = "SPLIT_TUNNEL_ON"
}

This works without issue.

If I change base_url to https://[company_name].openvpn.com... in this case I accidentialy leave out the .api., I get an opaque error:

Planning failed. OpenTofu encountered an error while generating this plan.

╷
│ Error: Plugin did not respond
│
│   with provider["registry.opentofu.org/openvpn/cloudconnexa"],
│   on main.tofu line 3, in provider "cloudconnexa":
│    3: provider "cloudconnexa" {
│
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain
│ more details.
╵

Stack trace from the terraform-provider-cloudconnexa_v1.0.1 plugin:

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

goroutine 46 [running]:
github.com/OpenVPN/terraform-provider-cloudconnexa/cloudconnexa.providerConfigure({0xd323d7?, 0x6?}, 0xc000119300)
        github.com/OpenVPN/terraform-provider-cloudconnexa/cloudconnexa/provider.go:93 +0x15a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).Configure(0xc00026ddc0, {0xe6c590, 0xc00037dad0}, 0xc00025ac80)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/provider.go:391 +0x228
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ConfigureProvider(0xc000358558, {0xe6c590?, 0xc00037d6e0?}, 0xc000162320)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:647 +0x3c5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).Configure(0xc000275040, {0xe6c590?, 0xc00037cd80?}, 0xc00025a780)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:587 +0x342
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_Configure_Handler({0xd13880, 0xc000275040}, {0xe6c590, 0xc00037cd80}, 0xc000118b00, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:557 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000140a00, {0xe6c590, 0xc00037cd20}, 0xc0002728a0, 0xc00037c300, 0x13fdb90, 0x0)
        google.golang.org/[email protected]/server.go:1392 +0xfc3
google.golang.org/grpc.(*Server).handleStream(0xc000140a00, {0xe6cdf8, 0xc0000fe000}, 0xc0002728a0)
        google.golang.org/[email protected]/server.go:1802 +0xbaa
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/[email protected]/server.go:1030 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 7
        google.golang.org/[email protected]/server.go:1041 +0x125

Error: The terraform-provider-cloudconnexa_v1.0.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.

This behavior is the same if I have a typo in my url or the API server is unavailable for some reason.

When the API endpoint is unavailable an error message should reflect that. Maybe something like:

Error: Unable to connect to CloudConnexa API endpoint https://[whatever was set in base_url]. Is provider base_url set correctly?

I'll see if I can find examples other providers errors in similar cases.

Relates to #106

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions