grafana / terraform-provider-grafana

Terraform Grafana provider
https://www.terraform.io/docs/providers/grafana/
Mozilla Public License 2.0
425 stars 225 forks source link

[Bug]: ImportResourceState request was cancelled. #1783

Open craigmonson opened 1 month ago

craigmonson commented 1 month ago

Terraform Version

1.8.4

Terraform Grafana Provider Version

3.7.0

Grafana Version

cloud

Affected Resource(s)

Terraform Configuration Files

provider "grafana" {
  url                       = "https://xxxxxxxxxxx.grafana.net"
  cloud_access_policy_token = var.grafana_token
}

resource "grafana_data_source" "test" {
  type = "cloudwatch"
  name = "CloudWatch-test

  json_data_encoded = jsonencode({
    defaultRegion = "us-west-2"
    authType      = "keys"
  })
}

Expected Behavior

Shouldn't panic

Actual Behavior

go panic:

╷
│ Error: Request cancelled
│
│ The plugin.(*GRPCProvider).ImportResourceState request was cancelled.
╵

Stack trace from the terraform-provider-grafana_v3.7.0 plugin:

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

goroutine 81 [running]:
github.com/grafana/grafana-openapi-client-go/client.(*GrafanaHTTPAPI).Clone(...)
        github.com/grafana/grafana-openapi-client-go@v0.0.0-20240723170622-ae2c94b7c9a3/client/grafana_http_api_client.go:173
github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana.OAPIClientFromExistingOrgResource({0x103449c0, 0xc000070960}, {0xc00011a3c0?, 0x0?})
        github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana/oss_org_id.go:73 +0x77
github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana.resourceDataSource.func1({0x10685a28?, 0xc0009984b0?}, 0xc00065f180, {0x103449c0, 0xc000070960})
        github.com/grafana/terraform-provider-grafana/v3/internal/resources/grafana/resource_data_source.go:40 +0xcc
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc0005bb570, {0x10685a28, 0xc0009984b0}, 0xc00085d5b0, {0xc00011a3c0, 0x24})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/provider.go:475 +0x197
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc0000109a8, {0x10685a28?, 0xc0009983f0?}, 0xc000869470)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1265 +0x605
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ImportResourceState(0xc0005bb5e0, {0x10685a28?, 0xc0008694d0?}, 0xc000869470)
        github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5muxserver/mux_server_ImportResourceState.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ImportResourceState(0xc0005c0d20, {0x10685a28?, 0xc000868b40?}, 0xc00082ba40)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:896 +0x265
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ImportResourceState_Handler({0x105f24e0, 0xc0005c0d20}, {0x10685a28, 0xc000868b40}, 0xc00065e300, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:536 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0007ec400, {0x10685a28, 0xc000868a80}, {0x1068f080, 0xc000017980}, 0xc0008c4000, 0xc000761860, 0x116b2dd0, 0x0)
        google.golang.org/grpc@v1.65.0/server.go:1379 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc0007ec400, {0x1068f080, 0xc000017980}, 0xc0008c4000)
        google.golang.org/grpc@v1.65.0/server.go:1790 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.65.0/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 69
        google.golang.org/grpc@v1.65.0/server.go:1040 +0x125

Error: The terraform-provider-grafana_v3.7.0 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.

Steps to Reproduce

  1. `terraform import grafana_data_source.test xxxxx-xxxxxx-xxxxx-xxxxx-xxxxx

Important Factoids

No response

References

No response