integrations / integrations/terraform-provider-github

[BUG]: Cannot add collaborators to newly created repos with provider version > v6.12.0

Open
#3,435 3 comments 1 reaction 0 assignees View on GitHub
Awaiting response Status: Invalid/Incomplete Status: Triage Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

I am able to create a repository and afterwards add collaborators to the repository, confirmed to be working with v6.11.1 and below.

### Actual Behavior

With version 6.12.1:
```
* Failed to execute "terraform apply" in ./.terragrunt-cache/rFr3LQxBfUVZaln86ORI_lMAdg8/P5du8EcWBbhwGOIxkzdXOTR_kdw

│ Error: GET https:///api/v3/repos///actions/permissions/access: 404 Not Found []

│ with github_actions_repository_access_level.reusable_workflows[0],
│ on main.tf line 319, in resource "github_actions_repository_access_level" "reusable_workflows":
│ 319: resource "github_actions_repository_access_level" "reusable_workflows" {

exit status 1
```
With version 6.12.0:
```
* Failed to execute "terraform apply" in ./.terragrunt-cache/Za6KsM-JUicb8pjzqyVZiKIVh2I/P5du8EcWBbhwGOIxkzdXOTR_kdw

│ Error: Plugin did not respond

│ with github_repository_collaborators.repo_collaborator,
│ on main.tf line 75, in resource "github_repository_collaborators" "repo_collaborator":
│ 75: resource "github_repository_collaborators" "repo_collaborator" {

│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.


│ Error: Plugin did not respond

│ with github_branch_protection.main[0],
│ on main.tf line 117, in resource "github_branch_protection" "main":
│ 117: resource "github_branch_protection" "main" {

│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.

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

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

goroutine 178 [running]:
github.com/integrations/terraform-provider-github/v6/github.updateUserCollaboratorsAndInvites({0x125fc10, 0x21eafca04690}, 0x21eafc55e508, {0x21eafc1ca260, 0xa}, {0x21eafc09de30, 0x10}, {0x21eafc667680, 0x2, 0x2})
github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_collaborators.go:694 +0xe09
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRepositoryCollaboratorsCreate({0x125fc10, 0x21eafca04690}, 0x21eafc78e5a0, {0xf41c00?, 0x21eafc566000?})
github.com/integrations/terraform-provider-github/v6/github/resource_github_repository_collaborators.go:199 +0x3f1
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x21eafc420f00, {0x125fb68, 0x21eafc59a600}, 0x21eafc78e5a0, {0xf41c00, 0x21eafc566000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.38.2/helper/schema/resource.go:849 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x21eafc420f00, {0x125fb68, 0x21eafc59a600}, 0x21eafc442c30, 0x21eafc78e480, {0xf41c00, 0x21eafc566000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.38.2/helper/schema/resource.go:980 +0xafd
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x21eafbfb8018, {0x125fb68?, 0x21eafc59a540?}, 0x21eafc666280)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.38.2/helper/schema/grpc_provider.go:1499 +0x10c9
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x21eafc1d00a0, {0x125fb68?, 0x21eafc36dc80?}, 0x21eafc0a2280)
github.com/hashicorp/terraform-plugin-go@v0.29.0/tfprotov5/tf5server/server.go:944 +0x3b9
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x11ad380, 0x21eafc1d00a0}, {0x125fb68, 0x21eafc36dc80}, 0x21eafc0a2000, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.29.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:789 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0x21eafc1c6200, {0x125fb68, 0x21eafc36c840}, 0x21eafc1cea20, 0x21eafc602750, 0x1c038e8, 0x0)
google.golang.org/grpc@v1.75.1/server.go:1431 +0xfdc
google.golang.org/grpc.(*Server).handleStream(0x21eafc1c6200, {0x12604c8, 0x21eafc3509c0}, 0x21eafc1cea20)
google.golang.org/grpc@v1.75.1/server.go:1842 +0xb88
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/grpc@v1.75.1/server.go:1061 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 38
google.golang.org/grpc@v1.75.1/server.go:1072 +0x11d

Error: The terraform-provider-github_v6.12.0 plugin crashed!
```

### Terraform Version

Terraform v1.15.1
on linux_amd64

### GitHub Installation Type

- [ ] GitHub.com (Free, Pro, or Team)
- [x] GitHub Enterprise Server (on-premises)
- [ ] GitHub Enterprise Cloud with Personal Accounts (github.com)
- [ ] GitHub Enterprise Cloud with Managed Users/EMU (github.com)
- [ ] GitHub Enterprise Cloud with Data Residency (*.ghe.com)
- [ ] I don't know

### Affected Resource(s)

- github_repository_collaborators

### Terraform Configuration Files

```hcl
resource "github_repository_collaborators" "repo_collaborator" {
repository = github_repository.repo.name

dynamic "user" {
for_each = var.repository_collaborator_users
content {
username = user.key
permission = user.value
}
}

dynamic "team" {
for_each = var.repository_collaborator_teams
content {
team_id = data.github_team.teams[team.key].id
permission = team.value
}
}

team {
permission = "pull"
team_id = data.github_team.security_managers.id
}
}
```

### Steps to Reproduce

_No response_

### Debug Output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.