DrFaust92 / terraform-provider-bitbucket

Terraform Bitbucket Cloud provider.
https://registry.terraform.io/providers/drfaust92/bitbucket
Mozilla Public License 2.0
38 stars 30 forks source link

Import repository failing #174

Open MichaelReubenDevSlalom opened 1 year ago

MichaelReubenDevSlalom commented 1 year ago

Hi there,

Terraform Version

Terraform is running on the latest version, I'm creating a docker image weekly that will download the latest terraform version, the command here ran on a bitbucket pipeline, I created a custom pipeline to import resources.

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

terraform {
  required_providers {
    bitbucket = {
      source  = "DrFaust92/bitbucket"
      version = "2.35.0"
    }
  }
}

provider "bitbucket" {} // Using OAuth consumer with Env Vars 

resource "bitbucket_repository" "situate" {
  name              = "x"
  owner             = "x"
  project_key       = "x"
  description       = "x"
  is_private        = true
  pipelines_enabled = true
}

Panic Output

Stack trace from the terraform-provider-bitbucket_v2.35.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xcb2033]

Expected Behavior

The Repository should have been imported and added into state

Actual Behavior

Logs from import command:

+ terraform import $importCommand
Acquiring state lock. This may take a few moments...
bitbucket_repository.situate: Importing from ID "$DOCKER_HUB_USERNAME/situate_tooling"...
bitbucket_repository.situate: Import prepared!
  Prepared bitbucket_repository for import
bitbucket_repository.situate: Refreshing state... [id=$DOCKER_HUB_USERNAME/situate_tooling]
╷
│ Error: Plugin did not respond
│ 
│ 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-bitbucket_v2.35.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xcb2033]
goroutine 84 [running]:
github.com/terraform-providers/terraform-provider-bitbucket/bitbucket.resourceRepositoryRead({0x0?, 0x0?}, 0xc0000eca80, {0xdb5f00?, 0xc00042b7c0?})
    github.com/terraform-providers/terraform-provider-bitbucket/bitbucket/resource_repository.go:325 +0x3d3
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfc16e0?, {0xfc16e0?, 0xc00018b1d0?}, 0xd?, {0xdb5f00?, 0xc00042b7c0?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:745 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003ba540, {0xfc16e0, 0xc00018b1d0}, 0xc0001bf110, {0xdb5f00, 0xc00042b7c0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:1044 +0x59e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0003a4168, {0xfc16e0?, 0xc00018b0b0?}, 0xc00048e9c0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:616 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0003a00a0, {0xfc16e0?, 0xc00018a6f0?}, 0xc0001156e0)
    github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:751 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xe3be40?, 0xc0003a00a0}, {0xfc16e0, 0xc00018a6f0}, 0xc000232230, 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(0xc00019e1e0, {0xfc5478, 0xc0003d0680}, 0xc0000eb7a0, 0xc0003b4a50, 0x150b3b0, 0x0)
    google.golang.org/grpc@v1.56.2/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc00019e1e0, {0xfc5478, 0xc0003d0680}, 0xc0000eb7a0, 0x0)
    google.golang.org/grpc@v1.56.2/server.go:1714 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.56.2/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.56.2/server.go:957 +0x18c
Error: The terraform-provider-bitbucket_v2.35.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.

Steps to Reproduce

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

  1. terraform apply with the repository
  2. terraform state rm bitbucket_repository.x
  3. create the configuration in a new directory
  4. terraform import bitbucket_repository.x owner/repo_name

Important Factoids

Using Google Cloud for Remote state, same Bucket different prefix for the old and new states

References

None that I can see.

I'm probably going to delete the repository and just re-create it in the new state, as I haven't committed to it yet but I think this is important to fix.

DrFaust92 commented 1 year ago

MichaelReubenDevSlalom can you try latest provider version?

Horkyze commented 1 month ago

Im also hitting this error with latest provider version.

$ terraform import bitbucket_repository.example example/example
bitbucket_repository.infra: Importing from ID "example/example"...
bitbucket_repository.infra: Import prepared!
  Prepared bitbucket_repository for import
bitbucket_repository.infra: Refreshing state... [id=example/example]
╷
│ Error: Plugin did not respond
│ 
│ 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-bitbucket_v2.42.0 plugin:

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

goroutine 27 [running]:
github.com/terraform-providers/terraform-provider-bitbucket/bitbucket.resourceRepositoryRead({0x0?, 0x0?}, 0xc0003bad80, {0xdae000?, 0xc00038cdc0?})
        github.com/terraform-providers/terraform-provider-bitbucket/bitbucket/resource_repository.go:348 +0x833
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfd1c58?, {0xfd1c58?, 0xc0003ccff0?}, 0xd?, {0xdae000?, 0xc00038cdc0?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.32.0/helper/schema/resource.go:790 +0x7a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0002fe700, {0xfd1c58, 0xc0003ccff0}, 0xc0003b0dd0, {0xdae000, 0xc00038cdc0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.32.0/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0002e84c8, {0xfd1c58?, 0xc0003ccf00?}, 0xc0002effc0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.32.0/helper/schema/grpc_provider.go:666 +0x48a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc00024a280, {0xfd1c58?, 0xc0003cc540?}, 0xc0003908a0)
        github.com/hashicorp/terraform-plugin-go@v0.21.0/tfprotov5/tf5server/server.go:774 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xe4d340?, 0xc00024a280}, {0xfd1c58, 0xc0003cc540}, 0xc0003ba800, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.21.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:482 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000111000, {0xfd1c58, 0xc0003cc4b0}, {0xfd6038, 0xc000318820}, 0xc0003bdd40, 0xc0002edbc0, 0x156f808, 0x0)
        google.golang.org/grpc@v1.61.0/server.go:1385 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc000111000, {0xfd6038, 0xc000318820}, 0xc0003bdd40)
        google.golang.org/grpc@v1.61.0/server.go:1796 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.61.0/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
        google.golang.org/grpc@v1.61.0/server.go:1040 +0x135

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