dbt-labs / terraform-provider-dbtcloud

dbt Cloud Terraform Provider
https://registry.terraform.io/providers/dbt-labs/dbtcloud
MIT License
80 stars 18 forks source link

segmentation violation code=0x1 addr=0x0 pc=0xaab1f8 #247

Closed kpucynski closed 2 months ago

kpucynski commented 2 months ago

Describe the bug

If token is set thru env variable and variable is empty plugin is crashing with SIGSEGV.

Error message

Planning failed. Terraform encountered an error while generating this plan.
|
│ Error: Plugin did not respond
│ 
│   with provider["registry.terraform.io/dbt-labs/dbtcloud"],
│   on providers.tf line 16, in provider "dbtcloud":
│   16: provider "dbtcloud" {
│ 
│ 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-dbtcloud_v0.2.23 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaab1f8]
goroutine 25 [running]:
github.com/dbt-labs/terraform-provider-dbtcloud/pkg/dbt_cloud.NewClient(0x0, 0x0, 0x0)
    github.com/dbt-labs/terraform-provider-dbtcloud/pkg/dbt_cloud/client.go:96 +0x98
github.com/dbt-labs/terraform-provider-dbtcloud/pkg/provider.providerConfigure({0xc8ad14?, 0x6?}, 0xc000310600?)
    github.com/dbt-labs/terraform-provider-dbtcloud/pkg/provider/provider.go:154 +0x21c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).Configure(0xc0000950e0, {0xdb5ec8, 0xc000310600}, 0xc000455090)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/provider.go:306 +0x222
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ConfigureProvider(0xc000307b00, {0xdb5ec8?, 0xc000310180?}, 0xc000446c30)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/grpc_provider.go:605 +0x3a9
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).Configure(0xc0001cac80, {0xdb5ec8?, 0xc0001f1920?}, 0xc00042fcc0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:597 +0x2ba
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_Configure_Handler({0xc5ff60?, 0xc0001cac80}, {0xdb5ec8, 0xc0001f1920}, 0xc00044cee0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:413 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001961e0, {0xdba440, 0xc00032d380}, 0xc0000fc360, 0xc000311b30, 0x12b9290, 0x0)
    google.golang.org/grpc@v1.57.1/server.go:[135](https://gitlab.com/JohnLewisPartnership/jlp-data-platform/data-engineering/pdp/pdp-platform/dbt/service-token/-/jobs/6583105178#L135)8 +0xe15
google.golang.org/grpc.(*Server).handleStream(0xc0001961e0, {0xdba440, 0xc00032d380}, 0xc0000fc360, 0x0)
    google.golang.org/grpc@v1.57.1/server.go:1735 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.57.1/server.go:970 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 16
    google.golang.org/grpc@v1.57.1/server.go:981 +0x145
Error: The terraform-provider-dbtcloud_v0.2.23 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.

Resource configuration

provider "dbtcloud" {
  # Configuration options
  account_id = var.dbt_cloud_account_id
  token      = var.dbt_cloud_token
  host_url   = "https://emea.dbt.com/api"
}

Expected behavior

Error code about the token not set/connection problem.

Config (please complete the following information):

b-per commented 2 months ago

Thanks for the report!

I have a fix for it now. But as it doesn't feel super urgent I will include it in the next release rather than doing a new release with just this change.