integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
886 stars 726 forks source link

[BUG]: panic when attempting to import `github_repository_autolink_reference` with invalid key #2163

Closed bradam12 closed 6 months ago

bradam12 commented 6 months ago

Expected Behavior

Error: cannot find autolink reference KEY- in repo my-org/my-repo

Actual Behavior

Panic error

Terraform Version

Terraform v1.5.4 on darwin_arm64

Affected Resource(s)

Terraform Configuration Files

resource "github_repository_autolink_reference" "autolink_KEY" {
    is_alphanumeric     = false
    key_prefix          = "KEY-"
    repository          = "my-repo"
    target_url_template = "https://ourjira.atlassian.net/browse/KEY-<num>"
}

Steps to Reproduce

$ terraform import github_repository_autolink_reference.autolink_KEY my-repo/KEY-

Debug Output

No response

Panic Output

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

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

goroutine 546 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryAutolinkReference.func1(0x14000114d00, {0x100dd4560, 0x14000710840})
        github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_autolink_reference.go:47 +0x150
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0x140000a5200, {0x100fb8ce0, 0x1400014f860}, 0x140007ab558, {0x1400039a360, 0x1a})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/provider.go:396 +0x14c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0x14000337f50, {0x100fb8ce0?, 0x1400014f500?}, 0x140008840a0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1144 +0xa4
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ImportResourceState(0x140002555e0, {0x100fb8ce0?, 0x1400014e9f0?}, 0x140005005a0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/tf5server/server.go:889 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ImportResourceState_Handler({0x100f6fec0, 0x140002555e0}, {0x100fb8ce0, 0x1400014e9f0}, 0x14000114a80, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:521 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400024c1e0, {0x100fb8ce0, 0x1400014e960}, {0x100fbd4f8, 0x1400017e000}, 0x1400027ea20, 0x14000284b10, 0x10160b6b0, 0x0)
        google.golang.org/grpc@v1.60.0/server.go:1372 +0xb40
google.golang.org/grpc.(*Server).handleStream(0x1400024c1e0, {0x100fbd4f8, 0x1400017e000}, 0x1400027ea20)
        google.golang.org/grpc@v1.60.0/server.go:1783 +0xc00
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.0/server.go:1016 +0x5c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 20
        google.golang.org/grpc@v1.60.0/server.go:1027 +0x124

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

Code of Conduct