integrations / terraform-provider-github

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

[BUG]: github_repository_ruleset resource crashes when merge queues are enabled #2192

Open siddharthab opened 5 months ago

siddharthab commented 5 months ago

Expected Behavior

  1. Create and deploy a github_repository_ruleset resource with Terraform.
  2. Through some other API or web console, enable merge queues in the ruleset.
  3. Run terraform plan. This step should succeed and show no changes (until merge queues are supported in Terraform).

Actual Behavior

On running terraform plan, the plugin crashes.

Terraform Version

Terraform v1.7.4 on darwin_arm64 + provider registry.terraform.io/integrations/github v6.0.1

Affected Resource(s)

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

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

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

goroutine 162 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryRulesetRead(0x14000608300, {0x105870f60?, 0x14000258b40?})
    github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_ruleset.go:480 +0x494
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x105a59be0?, {0x105a59be0?, 0x1400042ba70?}, 0xd?, {0x105870f60?, 0x14000258b40?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:783 +0x130

Code of Conduct

shmargum commented 3 months ago

this also appears to be the case for required_workflows on linux_amd64 (github hosted runners) i could not reproduce the issue on mac both on terraform 1.8.2 and github provider 6.2.1 this seems related to https://github.com/integrations/terraform-provider-github/issues/2113

Stack trace from the terraform-provider-github_v6.2.1 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xc607ad]
goroutine 51 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubOrganizationRulesetRead(0xc00045a700, {0xd1eb40?, 0xc0000a8a80?})
    github.com/integrations/terraform-provider-github/v6/github/resource_github_organization_ruleset.go:525 +0x56d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x10569d0?, {0x10569d0?, 0xc000464f30?}, 0xd?, {0xd1eb40?, 0xc0000a8a80?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:783 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000e5c00, {0x10569d0, 0xc000464f30}, 0xc000297ba0, {0xd1eb40, 0xc0000a8a80})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:1089 +0x529
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000010270, {0x10569d0?, 0xc000464e70?}, 0xc0000a9cc0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:667 +0x4aa
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000404640, {0x10569d0?, 0xc0004644e0?}, 0xc000092ba0)
grantcarthew commented 3 months ago

Same here for "Require code scanning results".

Deploy ruleset, change in the browser, and terraform plan. I don't think the code scanning is supported yet, but either way:

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

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

goroutine 193 [running]:
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryRulesetRead(0xc00058cf80, {0xd1eb40?, 0xc000532800?})
    github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_ruleset.go:480 +0x567
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x10569d0?, {0x10569d0?, 0xc0004cfa70?}, 0xd?, {0xd1eb40?, 0xc000532800?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:783 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003f9260, {0x10569d0, 0xc0004cfa70}, 0xc0005275f0, {0xd1eb40, 0xc000532800})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:1089 +0x529
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000376540, {0x10569d0?, 0xc0004cf9b0?}, 0xc00071c580)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:667 +0x4aa
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000277680, {0x10569d0?, 0xc0004cf230?}, 0xc0009bc7e0)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:775 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xebdec0, 0xc000277680}, {0x10569d0, 0xc0004cf230}, 0xc00058cc00, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:482 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019b000, {0x10569d0, 0xc0004cf1a0}, {0x105b258, 0xc00039f520}, 0xc000b12a20, 0xc000480150, 0x16d9a08, 0x0)
    google.golang.org/grpc@v1.61.1/server.go:1385 +0xdd1
google.golang.org/grpc.(*Server).handleStream(0xc00019b000, {0x105b258, 0xc00039f520}, 0xc000b12a20)
    google.golang.org/grpc@v1.61.1/server.go:1796 +0xfb8
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.61.1/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 15
    google.golang.org/grpc@v1.61.1/server.go:1040 +0x125

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