terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

[BUG]: provider crash when creating github_repository_deployment_branch_policy

Open samtarplee opened this issue 1 year ago • 0 comments

Expected Behavior

This should create a github_repository_deployment_branch_policy resource

Actual Behavior

The provider crashed. Error: The terraform-provider-github_v6.3.0 plugin crashed!

Terraform Version

Terraform v1.9.5 on linux_amd64

  • provider registry.terraform.io/integrations/github v6.3.0

Affected Resource(s)

  • github_repository_deployment_branch_policy

Terraform Configuration Files

## Create Environments
resource "github_repository_environment" "deploy_environments" {
  environment         = "control_plane-deploy"
  repository          = data.github_repository.repo.id
  prevent_self_review = true
  deployment_branch_policy {
    protected_branches     = false
    custom_branch_policies = true
  }
}

resource "github_repository_environment" "planning_environments" {
  environment = "control_plane-plan"
  repository  = data.github_repository.repo.id
}

resource "github_repository_deployment_branch_policy" "deploy_environments" {
  depends_on       = [github_repository_environment.deploy_environments]
  repository       = data.github_repository.repo.id
  environment_name = github_repository_environment.deploy_environments.environment
  name             = "main"
}

# I'm not going to include the repo/org names
data "github_repository" "repo" {
  full_name = "${var.github_organisation}/${var.github_team_name}"
}

Steps to Reproduce

This only happens if the github_repository_deployment_branch_policy exists but isn't in the state, and it tries to create a new one. I think it's related to #1818 , but this is a different resource and that one has a comment saying it was resolved in v5.3.0.

Plan runs fine too, only happens on an apply $ terraform apply $ terraform state rm github_repository_deployment_branch_policy.deploy_environments $ terraform apply

Debug Output

github_repository_deployment_branch_policy.deploy_environments: Creating...
2024-09-26T15:45:43.425Z [DEBUG] github_repository_deployment_branch_policy.deploy_environments: applying the planned Create change
2024-09-26T15:45:43.582Z [INFO]  provider.terraform-provider-github_v6.3.0: 2024/09/26 15:45:43 [DEBUG] Sleeping 1s between operations: timestamp=2024-09-26T15:45:43.582Z
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: panic: runtime error: invalid memory address or nil pointer dereference
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc8a51d]
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: goroutine 58 [running]:
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryDeploymentBranchPolicyCreate(0xc0000f2980, {0xd23ba0, 0xc0006d2480})
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_deployment_branch_policy.go:88 +0x2fd
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1062030?, {0x1062030?, 0xc0003f0960?}, 0xd?, {0xd23ba0?, 0xc0006d2480?})
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:794 +0x15f
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003aafc0, {0x1062030, 0xc0003f0960}, 0xc0002a1ba0, 0xc0000f2800, {0xd23ba0, 0xc0006d2480})
2024-09-26T15:45:44.674Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:937 +0xa89
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0000c8a98, {0x1062030?, 0xc0003f08a0?}, 0xc000100820)
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1153 +0xd5c
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0000cc6e0, {0x1062030?, 0xc00029dbf0?}, 0xc000225420)
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:865 +0x3d0
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xec8a80, 0xc0000cc6e0}, {0x1062030, 0xc00029dbf0}, 0xc00020dc80, 0x0)
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000fa000, {0x1062030, 0xc00029db60}, {0x1066930, 0xc0002d6180}, 0xc0007ccc60, 0xc00029d650, 0x16ec538, 0x0)
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	google.golang.org/[email protected]/server.go:1369 +0xdf8
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: google.golang.org/grpc.(*Server).handleStream(0xc0000fa000, {0x1066930, 0xc0002d6180}, 0xc0007ccc60)
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	google.golang.org/[email protected]/server.go:1780 +0xe8b
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: google.golang.org/grpc.(*Server).serveStreams.func2.1()
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	google.golang.org/[email protected]/server.go:1019 +0x8b
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
2024-09-26T15:45:44.675Z [DEBUG] provider.terraform-provider-github_v6.3.0: 	google.golang.org/[email protected]/server.go:1030 +0x125
Error: -26T15:45:44.677Z [ERROR] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.3.0/linux_amd64/terraform-provider-github_v6.3.0 id=1826 error="exit status 2"
2024-09-26T15:45:44.677Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
Error: -26T15:45:44.677Z [ERROR] plugin.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-09-26T15:45:44.677Z [DEBUG] State storage *remote.State declined to persist a state snapshot
Error: -26T15:45:44.677Z [ERROR] vertex "github_repository_deployment_branch_policy.deploy_environments" error: Plugin did not respond

Panic Output

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

goroutine 55 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryDeploymentBranchPolicyCreate(0xc0007ea200, {0xd23ba0, 0xc0004318c0})
	github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_deployment_branch_policy.go:88 +0x2fd
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1062030?, {0x1062030?, 0xc0002a2f00?}, 0xd?, {0xd23ba0?, 0xc0004318c0?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:794 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003b5dc0, {0x1062030, 0xc0002a2f00}, 0xc00077f790, 0xc0007ea080, {0xd23ba0, 0xc0004318c0})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:937 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000386678, {0x1062030?, 0xc0002a2bd0?}, 0xc0001d4a00)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000237720, {0x1062030?, 0xc0001b46f0?}, 0xc000220230)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xec8a80, 0xc000237720}, {0x1062030, 0xc0001b46f0}, 0xc00019f780, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019b000, {0x1062030, 0xc0001b4660}, {0x1066930, 0xc0002d6180}, 0xc0007e1320, 0xc00047e7b0, 0x16ec538, 0x0)
	google.golang.org/[email protected]/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00019b000, {0x1066930, 0xc0002d6180}, 0xc0007e1320)
	google.golang.org/[email protected]/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/[email protected]/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 9
	google.golang.org/[email protected]/server.go:1030 +0x125

Error: The terraform-provider-github_v6.3.0 plugin crashed!

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

samtarplee avatar Sep 26 '24 15:09 samtarplee