jdamata / terraform-provider-sonarqube

Terraform provider for managing Sonarqube configuration
GNU General Public License v3.0
62 stars 50 forks source link

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

Open srtab opened 4 months ago

srtab commented 4 months ago

Terraform Version

Terraform v1.7.4 jdamata/sonarqube v0.16.10

Affected Resource(s)

Terraform Configuration Files

resource "sonarqube_project" "this" {
  name       = "project name"
  project    = "project-key"
  visibility = "private"

  setting {
    key    = "sonar.dbcleaner.branchesToKeepWhenInactive"
    values = ["master", "main", "release/*", "dev"]
  }
}

Expected Behavior

When I run a second terraform apply, I will see changes that will be applied.

Actual Behavior

I get the following error:

╷
│ Error: Plugin did not respond
│ 
│   with sonarqube_project.this,
│   on main.tf line 31, in resource "sonarqube_project" "this":
│   31: resource "sonarqube_project" "this" {
│ 
│ 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-sonarqube_v0.16.10 plugin:

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

goroutine 273 [running]:
github.com/jdamata/terraform-provider-sonarqube/sonarqube.resourceSonarqubeProjectRead(0xc000814480, {0xb5f200?, 0xc0002f43c0})
        github.com/jdamata/terraform-provider-sonarqube/sonarqube/resource_sonarqube_project.go:235 +0xd2f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xdc3d00?, {0xdc3d00?, 0xc000260cf0?}, 0xd?, {0xb5f200?, 0xc0002f43c0?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:783 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000b6e00, {0xdc3d00, 0xc000260cf0}, 0xc0001229c0, {0xb5f200, 0xc0002f43c0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:1089 +0x59e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00000d890, {0xdc3d00?, 0xc000260bd0?}, 0xc000726240)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/grpc_provider.go:616 +0x497
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0000b5220, {0xdc3d00?, 0xc0002603f0?}, 0xc00054c180)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:751 +0x49e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xc5d7c0?, 0xc0000b5220}, {0xdc3d00, 0xc0002603f0}, 0xc0001ac0e0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:386 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000001e0, {0xdc6a60, 0xc0002969c0}, 0xc000262360, 0xc0003cff50, 0x12705b0, 0x0)
        google.golang.org/grpc@v1.56.3/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0000001e0, {0xdc6a60, 0xc0002969c0}, 0xc000262360, 0x0)
        google.golang.org/grpc@v1.56.3/server.go:1712 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.3/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.3/server.go:958 +0x15c

Error: The terraform-provider-sonarqube_v0.16.10 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

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

  1. terraform apply - This will run with no problems;
  2. terraform apply - Second run, will raise the traceback error.
freeranger commented 4 months ago

@srtab this problem doesn't happen with 0.16.9 - perhaps you could use that version for the moment? @pnag90 This problem is with project creation and your changes for that went into 0.16.10 and seem to be the likely culprit: https://github.com/jdamata/terraform-provider-sonarqube/pull/202 Would you be able to take a look and fix the issue?