integrations / integrations/terraform-provider-github

[BUG]: github_repository_collaborator treats expired invitations as existing

Open
#3,645 1 comment 0 reactions 0 assignees View on GitHub
Status: Triage Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

When a `github_repository_collaborator` invitation has expired and the invited user has not become a collaborator, Terraform should treat the collaborator resource as absent.

A subsequent terraform plan / terraform apply should therefore recreate the resource and send a new repository invitation.

### Actual Behavior

The `github_repository_collaborator` resource appears to treat any matching invitation as existing without checking whether the invitation has expired.

As a result, Terraform reports no diff after the invitation expires and does not send a new invitation.

### Terraform Version

Terraform v1.12.1
on linux_amd64
+ provider github.com/integrations/github v6.13.0

### GitHub Installation Type

- [ ] GitHub.com (Free, Pro, or Team)
- [ ] GitHub Enterprise Server (on-premises)
- [x] 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_collaborator

### Terraform Configuration Files

```hcl
resource "github_repository_collaborator" "example" {
repository = "example-repository"
username = "example-user"
permission = "push"
}
```

### Steps to Reproduce

1. Configure an outside collaborator using `github_repository_collaborator`.
2. Run terraform apply.
3. Verify that GitHub sends a repository invitation to the user.
4. Do not accept the invitation and allow it to expire in 7 days.
5. Query the repository invitations API: `gh api repos///invitations`
6. Observe that GitHub still returns the invitation, but with:`"expired": true`
7. Verify that the user is not currently a collaborator: `gh api repos///collaborators/`
This should return 404.
8. Run terraform plan.
Observe that Terraform reports no change for the `github_repository_collaborator` resource and therefore does not recreate the resource or send a new invitation.

For comparison, organization membership invitations managed by `github_membership` are recreated after expiry, while expired repository collaborator invitations remain stuck in this state.

### Debug Output

```shell
$ gh api repos///invitations
[
{
"repository": {
"name": "",
"full_name": "/",
"private": true
},
"invitee": {
"login": "",
"type": "User"
},
"inviter": {
"login": "[bot]",
"type": "Bot"
},
"permissions": "read",
"created_at": "2026-08-10T04:22:52Z",
"expired": true
}
]

$ gh api repos///collaborators/
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest",
"status": "404"
}
```

### Code of Conduct

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

Contributor guide

Open the contributing guide

Research direction

Start at the github_repository_collaborator resource and its repository-invitations lookup, then compare the behavior with github_membership's expired-invitation handling. Reproduce with the listed gh api commands, including the expired field and collaborator 404; done means terraform plan treats an expired invitation as absent and a later apply can send a new invitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, go, terraform
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.