Skip to content

[BUG]: Provider crashes when trying to create duplicate environment protection rule #2967

@SMillerDev

Description

@SMillerDev

Expected Behavior

An error message about the resource existing and suggesting to import it instead

Actual Behavior

The plugin.(*GRPCProvider).ValidateResourceConfig request was cancelled.

Stack trace from the terraform-provider-github_v6.8.3 plugin:

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

goroutine 114 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryDeploymentBranchPolicyCreate(0xc00058ab80, {0xd49780, 0xc0002f6e40})
	github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_deployment_branch_policy.go:93 +0x33d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1096870?, {0x1096870?, 0xc00059ba40?}, 0xd?, {0xd49780?, 0xc0002f6e40?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:794 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003f2b60, {0x1096870, 0xc00059ba40}, 0xc00073b930, 0xc00058aa00, {0xd49780, 0xc0002f6e40})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:937 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00038c678, {0x1096870?, 0xc00059b980?}, 0xc000166960)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00027f9a0, {0x1096870?, 0xc00059b1a0?}, 0xc00024b3b0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xef6da0, 0xc00027f9a0}, {0x1096870, 0xc00059b1a0}, 0xc00058a780, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019d000, {0x1096870, 0xc00059b110}, {0x109b280, 0xc0002da180}, 0xc0005c0000, 0xc000471110, 0x173c578, 0x0)
	google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00019d000, {0x109b280, 0xc0002da180}, 0xc0005c0000)
	google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 26
	google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

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

Terraform Version

OpenTofu v1.10.7
on darwin_arm64

  • provider registry.opentofu.org/1password/onepassword v2.2.0
  • provider registry.opentofu.org/integrations/github v6.7.1
  • provider registry.opentofu.org/jdamata/sonarqube v0.16.17
  • provider registry.opentofu.org/jfrog/artifactory v12.10.1

Affected Resource(s)

  • github_repository_deployment_branch_policy

Terraform Configuration Files

resource "github_repository_deployment_branch_policy" "environment_test_deployment_policy" {
  repository       = github_repository.repo.name
  environment_name = "Test"
  name             = "develop"
}

Steps to Reproduce

  1. Create a environment deployment rule through the UI.
  2. Create configuration in TF for the same rule
$ terraform apply

Debug Output

Panic Output

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

goroutine 114 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryDeploymentBranchPolicyCreate(0xc00058ab80, {0xd49780, 0xc0002f6e40})
	github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_deployment_branch_policy.go:93 +0x33d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1096870?, {0x1096870?, 0xc00059ba40?}, 0xd?, {0xd49780?, 0xc0002f6e40?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:794 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003f2b60, {0x1096870, 0xc00059ba40}, 0xc00073b930, 0xc00058aa00, {0xd49780, 0xc0002f6e40})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:937 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00038c678, {0x1096870?, 0xc00059b980?}, 0xc000166960)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00027f9a0, {0x1096870?, 0xc00059b1a0?}, 0xc00024b3b0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xef6da0, 0xc00027f9a0}, {0x1096870, 0xc00059b1a0}, 0xc00058a780, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019d000, {0x1096870, 0xc00059b110}, {0x109b280, 0xc0002da180}, 0xc0005c0000, 0xc000471110, 0x173c578, 0x0)
	google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00019d000, {0x109b280, 0xc0002da180}, 0xc0005c0000)
	google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 26
	google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-github_v6.8.3 plugin crashed!
Terraform Version

Code of Conduct

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

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't working as documented

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions