Repository navigation
Description
Expected Behavior
Deleting a github_team_repository when the underlying Teams.RemoveTeamRepoByID call fails at the transport layer (for example a cancelled context or an exceeded deadline) should surface the error as a Terraform diagnostic, so the operation fails cleanly and can be retried.
Actual Behavior
The provider panics with a nil-pointer dereference. resourceGithubTeamRepositoryDelete reads resp.StatusCode without first checking whether resp is nil. When the API call returns a transport-level error, google/go-github returns a nil *github.Response (see bareDo: on a transport error resp is nil, so it returns (nil, err)), so the delete dereferences a nil pointer and the provider process crashes.
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV]
github.com/integrations/terraform-provider-github/v6/github.resourceGithubTeamRepositoryDelete(...)
github/resource_github_team_repository.go:226
This is the only unguarded resp.StatusCode dereference in the github/ package; the other call sites already use the resp != nil && resp.StatusCode pattern.
Terraform Version
Reproduced on main (v6, commit 4d34f10b). The bug was surfaced by the acceptance test suite (go test ./github/... -run TestAccGithubTeamRepository) when a parallel delete hit context deadline exceeded. The affected code path is reached by any terraform apply/destroy that deletes a github_team_repository when the delete API call returns a transport-level error (nil HTTP response).
Terraform vX.Y.Z (provider built from main @ 4d34f10b)
GitHub Installation Type
Observed against GitHub Enterprise Cloud, but the defect is installation-agnostic (a nil-pointer dereference on any transport error, independent of the GitHub edition).
- GitHub Enterprise Cloud with Personal Accounts (github.com)
Affected Resource(s)
- github_team_repository
Steps to Reproduce
Trigger a delete of a github_team_repository where RemoveTeamRepoByID returns a nil response (any transport error, such as a cancelled context or an exceeded deadline). This can be reproduced deterministically in a unit test that drives the delete with a cancelled context so the API call returns a nil response before reaching the server.
Debug Output
resource_github_actions_runner_group_test.go:90: Step 1/1 error: Error running apply: exit status 1
Error: context deadline exceeded
with github_repository.test,
on terraform_plugin_test.tf line 12, in resource "github_repository" "test":
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0]
github.com/integrations/terraform-provider-github/v6/github.resourceGithubTeamRepositoryDelete(...)
github/resource_github_team_repository.go:226
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).delete(...)
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
github-actions commentedon Jul 2, 2026
👋 Hi, and thank you for opening this issue!
This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.
You can help us prioritize by adding details, reproduction steps, or a 👍 to issues that matter to you, and by joining the discussion on open issues and PRs.
🤖 This is an automated message.