Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The terraform-provider-grafana_v1.40.1 plugin crashed! #921

Closed
Adrien2Adrien opened this issue May 30, 2023 · 1 comment · Fixed by #931
Closed

The terraform-provider-grafana_v1.40.1 plugin crashed! #921

Adrien2Adrien opened this issue May 30, 2023 · 1 comment · Fixed by #931
Labels

Comments

@Adrien2Adrien
Copy link

Terraform Version

  • Terraform: v1.4.6 on darwin_arm64
  • Terraform Grafana Provider: v1.40.1
  • Grafana: 8.1.8

Affected Resource(s)

  • grafana_dashboard
  • terraform_maintained

Terraform Configuration Files

Default configuration from https://registry.terraform.io/providers/hashicorp/google/latest/docs

Debug/Panic Output

Stack trace from the terraform-provider-grafana_v1.40.1 plugin:

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

goroutine 16 [running]:
github.com/grafana/terraform-provider-grafana/internal/resources/grafana.NormalizeDashboardConfigJSON({0x10377f520?, 0x140001bd770?})
        github.com/grafana/terraform-provider-grafana/internal/resources/grafana/resource_dashboard.go:366 +0x370
github.com/grafana/terraform-provider-grafana/internal/resources/grafana.ReadDashboard({0x1035779b0?, 0x140004d9230?}, 0x14000651700, {0x103717d20?, 0x140006476d0?})
        github.com/grafana/terraform-provider-grafana/internal/resources/grafana/resource_dashboard.go:257 +0x81c
github.com/grafana/terraform-provider-grafana/internal/provider.addResourcesMetadataValidation.func1({0x10388b508, 0x14000269860}, 0x0?, {0x103717d20, 0x140006476d0})
        github.com/grafana/terraform-provider-grafana/internal/provider/provider_validation.go:60 +0xe0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x140000f1ea0, {0x10388b540, 0x14000269110}, 0xd?, {0x103717d20, 0x140006476d0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:724 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x140000f1ea0, {0x10388b540, 0x14000269110}, 0x14000620750, {0x103717d20, 0x140006476d0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:1015 +0x46c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x140003f3e90, {0x10388b540?, 0x14000268ff0?}, 0x140004ce700)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:613 +0x400
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x140002195e0, {0x10388b540?, 0x14000675d70?}, 0x14000418600)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x3e8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x10384b8a0?, 0x140002195e0}, {0x10388b540, 0x14000675d70}, 0x1400064c850, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002141e0, {0x10388f4d8, 0x140003731e0}, 0x14000154480, 0x14000400ae0, 0x103e12d30, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1345 +0xc90
google.golang.org/grpc.(*Server).handleStream(0x140002141e0, {0x10388f4d8, 0x140003731e0}, 0x14000154480, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1722 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.54.0/server.go:966 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.54.0/server.go:964 +0x28c

Error: The terraform-provider-grafana_v1.40.1 plugin crashed!

Expected Behavior

What should have happened?

Terraform import should have imported the resource

Actual Behavior

What actually happened?

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

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create Grafana dashboard using Terraform
  2. run terraform import grafana_dashboard.terraform_maintained GC797v0Vz

If you need any more information, please let me know.
Thanks!
Adrien

@kaio6fellipe
Copy link

I had the same problem trying to import a data source.

root@69ec436162bf:/platform/stacks/grafana-cloud# terraform import grafana_data_source.testdata a478c1af-c9b1-42ad-a3f7-6a2d8633c05a 
Acquiring state lock. This may take a few moments...
grafana_data_source.testdata: Importing from ID "a478c1af-c9b1-42ad-a3f7-6a2d8633c05a"...
╷
│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ImportResourceState request was cancelled.
╵

Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-grafana_v1.40.1 plugin:

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

goroutine 65 [running]:
github.com/grafana/grafana-api-golang-client.(*Client).request(0x0, {0xe22d55, 0x3}, {0xc0004a8140, 0x39}, 0x1?, {0x0, 0x0, 0x0}, {0xcbdce0, ...})
        github.com/grafana/grafana-api-golang-client@v0.21.1/client.go:85 +0x106
github.com/grafana/grafana-api-golang-client.(*Client).DataSourceByUID(0xc00003e090?, {0xc00003e090?, 0x11?})
        github.com/grafana/grafana-api-golang-client@v0.21.1/datasource.go:93 +0xce
github.com/grafana/terraform-provider-grafana/internal/resources/grafana.ResourceDataSource.func1({0xf7a900?, 0xc000369830?}, 0xc000558400, {0xcbf9e0?, 0xc00029ee60})
        github.com/grafana/terraform-provider-grafana/internal/resources/grafana/resource_data_source.go:50 +0x1d9
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc000131500, {0xf7a900, 0xc000369830}, 0xc00010f620, {0xc00003e090, 0x24})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/provider.go:385 +0x1ac
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc000427de8, {0xf7a900?, 0xc000369710?}, 0xc0001383e0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:1088 +0xf4
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ImportResourceState(0xc00024b680, {0xf7a900?, 0xc0003684b0?}, 0xc0005480f0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:848 +0x1f6
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ImportResourceState_Handler({0xdf07e0?, 0xc00024b680}, {0xf7a900, 0xc0003684b0}, 0xc000554000, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:403 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002481e0, {0xf7e938, 0xc0004424e0}, 0xc000380000, 0xc000432ae0, 0x151ce18, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1345 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc0002481e0, {0xf7e938, 0xc0004424e0}, 0xc000380000, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1722 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.54.0/server.go:966 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.54.0/server.go:964 +0x28a

Error: The terraform-provider-grafana_v1.40.1 plugin crashed!

julienduchesne added a commit that referenced this issue Jun 5, 2023
julienduchesne added a commit that referenced this issue Jun 6, 2023
* Fix potential panic on dashboards
Closes #921

* Simplify access logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants