Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] github_actions_runner_group: invalid memory address or nil pointer dereference #1524

Closed
cwthrivent opened this issue Jan 31, 2023 · 4 comments · Fixed by #1696
Closed
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@cwthrivent
Copy link

cwthrivent commented Jan 31, 2023

It seems that the github_actions_runner_group resource and the github_repository data source types have memory errors starting on provider version v5.15.0. This issue is not present on v5.14.0 and earlier.

Copying logs from my comment from #1485 here:

resource "github_actions_runner_group" "beta_linux_runners" {
  name       = "beta-linux-runners"
  visibility = "all"
}
Error message (Terraform v1.3.0, provider v5.16.0)
Terraform v1.3.0
on linux_amd64
Initializing plugins and modules...

...

│ Error: Plugin did not respond
│ 
│   with github_actions_runner_group.beta_linux_runners,
│   on github-thrivent.tf line 19, in resource "github_actions_runner_group" "beta_linux_runners":
│   19: resource "github_actions_runner_group" "beta_linux_runners" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.

...
Stack trace
Stack trace from the terraform-provider-github_v5.16.0 plugin:

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

goroutine 65 [running]:
github.com/integrations/terraform-provider-github/v5/github.resourceGithubActionsRunnerGroupRead(0xc000518540, {0xeb2f80?, 0xc0005c6400?})
	github.com/integrations/terraform-provider-github/v5/github/resource_github_actions_runner_group.go:188 +0x82d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000149400, 0xc000590370, {0xeb2f80, 0xc0005c6400})
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:470 +0x1aa
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00011e8a8, {0xc000114600?, 0x4b86c6?}, 0xc000114600)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x34b
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler({0x105cba0?, 0xc00011e8a8}, {0x12c5730, 0xc000536270}, 0xc0001145a0, 0x0)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002ac380, {0x12c8e80, 0xc00048e1a0}, 0xc0005f0000, 0xc0002aeea0, 0x19845b0, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1283 +0xcfd
google.golang.org/grpc.(*Server).handleStream(0xc0002ac380, {0x12c8e80, 0xc00048e1a0}, 0xc0005f0000, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1620 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.46.2/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.46.2/server.go:920 +0x28a
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0xde71cd]

goroutine 41 [running]:
github.com/integrations/terraform-provider-github/v5/github.resourceGithubActionsRunnerGroupRead(0xc0000c9570, {0xeb2f80?, 0xc0001bcc40?})
	github.com/integrations/terraform-provider-github/v5/github/resource_github_actions_runner_group.go:188 +0x82d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000536e60, 0xc00086a2d0, {0xeb2f80, 0xc0001bcc40})
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:470 +0x1aa
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc0001150b8, {0xc00084c120?, 0x4b8746?}, 0xc00084c120)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x34b
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler({0x105cba0?, 0xc0001150b8}, {0x12c5730, 0xc00084ec60}, 0xc00084c0c0, 0x0)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000230a80, {0x12c8e80, 0xc000118820}, 0xc00015c480, 0xc000371350, 0x19845b0, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1283 +0xcfd
google.golang.org/grpc.(*Server).handleStream(0xc000230a80, {0x12c8e80, 0xc000118820}, 0xc00015c480, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1620 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.46.2/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.46.2/server.go:920 +0x28a
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0xde71cd]

goroutine 23 [running]:
github.com/integrations/terraform-provider-github/v5/github.resourceGithubActionsRunnerGroupRead(0xc00013e690, {0xeb2f80?, 0xc00028e340?})
	github.com/integrations/terraform-provider-github/v5/github/resource_github_actions_runner_group.go:188 +0x82d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000143d60, 0xc000735900, {0xeb2f80, 0xc00028e340})
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:470 +0x1aa
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00011a920, {0xc00073e2a0?, 0x4b86c6?}, 0xc00073e2a0)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x34b
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler({0x105cba0?, 0xc00011a920}, {0x12c5730, 0xc000768540}, 0xc00073e240, 0x0)
	github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fe380, {0x12c8e80, 0xc00030eb60}, 0xc000210a20, 0xc000435230, 0x19845b0, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1283 +0xcfd
google.golang.org/grpc.(*Server).handleStream(0xc0001fe380, {0x12c8e80, 0xc00030eb60}, 0xc000210a20, 0x0)
	google.golang.org/grpc@v1.46.2/server.go:1620 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.46.2/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.46.2/server.go:920 +0x28a

Error: The terraform-provider-github_v5.16.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.
@kfcampbell kfcampbell added Type: Bug Something isn't working as documented Status: Up for grabs Issues that are ready to be worked on by anyone Priority: Normal labels Feb 4, 2023
@kfcampbell
Copy link
Member

@cwthrivent thanks for catching this! The diff between v5.15.0 and v5.14.0 is here. Is there anything suspicious in there to you?

@aq17
Copy link

aq17 commented Mar 15, 2023

Hi all, one of our users of our Pulumi bridged provider is also hitting this and is unable to refresh this resource

@kfcampbell
Copy link
Member

That's obnoxious. I'm not seeing anything obvious in the diff...the data source for repositories doesn't look like it was touched at all during those versions.

@dbaur
Copy link
Contributor

dbaur commented May 24, 2023

Hi,

I think in case of the runner group the error is caused by an incorrect handling of the "Not Modified" Header.

The Runner Group logic tries to read the already existing Runner Group which will return a 304 and thus the returned runner group will be nil.

func getOrganizationRunnerGroup(client *github.Client, ctx context.Context, org string, groupID int64) (*github.RunnerGroup, *github.Response, error) {
	runnerGroup, resp, err := client.Actions.GetOrganizationRunnerGroup(ctx, org, groupID)
	if err != nil {
		if ghErr, ok := err.(*github.ErrorResponse); ok && ghErr.Response.StatusCode == http.StatusNotModified {
			// ignore error StatusNotModified
			return runnerGroup, resp, nil
		}
	}
	return runnerGroup, resp, err
}

This never was a problem as until the commit introducing the "selected_workflows" all attributes on the runnerGroup were accessed using the Get-Methods, which internally handle the case of the runnerGroup being null. However, the selected_workflows logic directly accesses the field on the runnerGroup which will cause a nil pointer.

Imho, the code simply needs an early return within the resourceGithubActionsRunnerGroupRead method in case the above mentioned method runs into a 304 response.

I can provide a pull request fixing this behavior if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants