jfrog/terraform-provider-platform

Provider crash after upgrading to `1.7.0`

Closed this issue · 4 comments

Describe the bug
Greetings!

After upgrading to version 1.7.0 of the platform provider we're seeing a stack trace from the provider during the plan phase. This happens even when just targeting the apply to a single resource within the platform provider.

╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ConfigureProvider request was cancelled.
╵

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

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

goroutine 5 [running]:
github.com/go-resty/resty/v2.(*Client).SetAuthToken(...)
	github.com/go-resty/resty/v2@v2.12.0/client.go:379
github.com/jfrog/terraform-provider-shared/client.AddAuth(0xc000092350?, {0x0?, 0x1?}, {0xc0000c8600?, 0xb42380?})
	github.com/jfrog/terraform-provider-shared@v1.23.0/client/client.go:49 +0x25
github.com/jfrog/terraform-provider-platform/pkg/platform.(*PlatformProvider).Configure(0xc000272e00, {0xd72e38, 0xc000096bd0}, {{0xc000012168, 0x5}, {{{0xd77438, 0xc0000973e0}, {0xb42380, 0xc0000972f0}}, {0xd78e48, ...}}}, ...)
	github.com/jfrog/terraform-provider-platform/pkg/platform/provider.go:137 +0x7ba
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ConfigureProvider(0xc0003561a0, {0xd72e38, 0xc000096bd0}, 0xc0000923c0, 0xc000092340)
	github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_configureprovider.go:18 +0x10c
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ConfigureProvider(0xc0003561a0, {0xd72e38?, 0xc000096ab0?}, 0xc000096a80?)
	github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/proto6server/server_configureprovider.go:39 +0x2f6
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ConfigureProvider(0xc000259180, {0xd72e38?, 0xc000096240?}, 0xc000092140)
	github.com/hashicorp/terraform-plugin-go@v0.22.1/tfprotov6/tf6server/server.go:558 +0x2db
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ConfigureProvider_Handler({0xc10e20?, 0xc000259180}, {0xd72e38, 0xc000096240}, 0xc0000ac000, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.22.1/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:464 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000145600, {0xd72e38, 0xc0000961b0}, {0xd77e00, 0xc0003576c0}, 0xc0000a0000, 0xc00034b830, 0x12648f0, 0x0)
	google.golang.org/grpc@v1.62.1/server.go:1386 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc000145600, {0xd77e00, 0xc0003576c0}, 0xc0000a0000)
	google.golang.org/grpc@v1.62.1/server.go:1797 +0x100c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.62.1/server.go:1027 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 28
	google.golang.org/grpc@v1.62.1/server.go:1038 +0x135

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

Sample main.tf:

resource "platform_license" "this" {
  name = "enterprise"
  key  = jsondecode(data.aws_secretsmanager_secret_version.artifactory.secret_string)["license"]
}

Our Artifactory is self-hosted and deployed to EKS. This behaviour does not occur when using version 1.6.0 of the platform provider.

  • Artifactory Version: 7.77.9
  • Terraform Version: 1.8.0
    • Also tried this with 1.7.5 but the behaviour is the same.
  • terraform-provider-platform version: 1.7.0
    • Works with 1.6.0

Requirements for and issue

  • A description of the bug
  • A fully functioning terraform snippet that can be copy&pasted (no outside files or ENV vars unless that's part of the issue). If this is not supplied, this issue will likely be closed without any effort expended.
  • Your version of artifactory (you can curl it at $host/artifactory/api/system/version
  • Your version of terraform
  • Your version of terraform provider

Expected behavior
The provider should not crash. 😄

Additional context
N/A

I was just about to create a new issue when I found this one and I encountered exactly the same bug on my side.

Good job opening this issue!

@9numbernine9 Thanks for the report! May I ask how is your provider configured? Can you share a sample of your configuration that includes the provider block?

@alexhung For sure! It's configured thusly:

provider "platform" {
  url          = data.terraform_remote_state.workloads.outputs.jfrog.artifactory_url
  access_token = jsondecode(data.aws_secretsmanager_secret_version.artifactory.secret_string)["terraform_access_token"]
}

Artifactory itself is deployed in a separate repo, hence the usage of remote_state to get the URL.

1.7.1 working perfectly - thanks @alexhung !