grafana / terraform-provider-grafana

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

data lookup for cloud_access_policies panics #1900

Open deepy opened 2 weeks ago

deepy commented 2 weeks ago

Terraform Version

1.4.7

Terraform Grafana Provider Version

3.13.1

Grafana Version

Grafana Cloud (steady)

Affected Resource(s)

Terraform Configuration Files

data "grafana_cloud_access_policies" "policies" {
  provider = grafana.cloud
}

provider "grafana" {
  alias = "cloud"
  auth = "123"
}

Expected Behavior

Error message telling me to use cloud_access_policy_token instead of auth

Actual Behavior

│ Error: Plugin did not respond
│
│   with data.grafana_cloud_access_policies.policies,
│   on main.tf line 45, in data "grafana_cloud_access_policies" "policies":
│   45: data "grafana_cloud_access_policies" "policies" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.
╵

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

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x104029494]

goroutine 57 [running]:
github.com/grafana/terraform-provider-grafana/v3/internal/resources/cloud.(*AccessPoliciesDataSource).Read(0x140006900b8, {0x1048cf778, 0x14000a9a1e0}, {{{{0x1048d8018, 0x14000a9b2c0}, {0x1045966e0, 0x14000a9b0e0}}, {0x1048dbf08, 0x14000a6e300}}, {{{0x0, ...}, ...}, ...}, ...}, ...)
    github.com/grafana/terraform-provider-grafana/v3/internal/resources/cloud/data_source_cloud_access_policies.go:96 +0x184
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadDataSource(0x140006561e0, {0x1048cf778, 0x14000a9a1e0}, 0x1400013bc00, 0x140009cf4d0)
    github.com/hashicorp/terraform-plugin-framework@v1.12.0/internal/fwserver/server_readdatasource.go:103 +0x638
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadDataSource(0x140006561e0, {0x1048cf778?, 0x14000a9a060?}, 0x14000a9a120)
    github.com/hashicorp/terraform-plugin-framework@v1.12.0/internal/proto6server/server_readdatasource.go:55 +0x2e0
github.com/hashicorp/terraform-plugin-mux/tf6to5server.v6tov5Server.ReadDataSource({{0x1048e13b0?, 0x140006561e0?}}, {0x1048cf778?, 0x14000a9a060?}, 0x14000a93620?)
    github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6to5server/tf6to5server.go:165 +0x254
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ReadDataSource(0x14000890d20, {0x1048cf778?, 0x14000a93680?}, 0x14000a93620)
    github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5muxserver/mux_server_ReadDataSource.go:36 +0x184
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0x1400089d900, {0x1048cf778?, 0x14000a92900?}, 0x14000ae22d0)
    github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov5/tf5server/server.go:688 +0x1cc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x10483eba0, 0x1400089d900}, {0x1048cf778, 0x14000a92900}, 0x14000a6a000, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:599 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000824400, {0x1048cf778, 0x14000a92870}, {0x1048d9c40, 0x1400013c000}, 0x14000a62000, 0x14000679aa0, 0x105915f60, 0x0)
    google.golang.org/grpc@v1.67.1/server.go:1394 +0xb64
google.golang.org/grpc.(*Server).handleStream(0x14000824400, {0x1048d9c40, 0x1400013c000}, 0x14000a62000)
    google.golang.org/grpc@v1.67.1/server.go:1805 +0xb20
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.67.1/server.go:1029 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
    google.golang.org/grpc@v1.67.1/server.go:1040 +0x13c

Error: The terraform-provider-grafana_v3.13.1 plugin crashed!

Steps to Reproduce

No response

Important Factoids

No response

References

No response

deepy commented 2 weeks ago

Forgetting to save providers.tf after replacing auth with cloud_access_policy_token will trigger this :P