Skip to content

[BUG]: github_repository_collaborators error on repository rename #2874

Closed

Description

@acouvreur

Expected Behavior

The github_repository_collaborators has the property repository which is used as the resource ID.

But changing a the repository property on a github_repository_collaborators can mean two things:

  • the collaborators are no longer assigned to the previous repository, and are now assigned to the new repository
  • the repository has been renamed

The ID should be set to the repository ID to properly delete the collaborators only of the ID changed.

Actual Behavior

The first case will work, the second will fail because it can no longer remove that repository by name from the collaborators.

Terraform Version

Terraform v1.13.3
on darwin_arm64

  • provider registry.terraform.io/integrations/github v6.6.0

Affected Resource(s)

  • github_repository_collaborators

Terraform Configuration Files

Steps to Reproduce

No response

Debug Output

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Type: Bug
    Status: Triage
    on Nov 7, 2025
  2. moved this from Backlog to In Progress in Terraform Provideron Nov 7, 2025
  3. acouvreur commented on Nov 7, 2025

    @acouvreur
    ContributorAuthor

    I have created a first draft for this change: #2876

    However, I don't think making API calls should be part of a refresh strategy when we can simply replace repository with repository_id.

    Then, when adding or removing the collaborators, query the repository name because the API does not provide such call through repository ID.

  4. acouvreur commented on Nov 7, 2025

    @acouvreur
    ContributorAuthor

    Another even simpler solution is to swallow 404 errors not found on deletion when calling client.Repositories.RemoveCollaborator

  5. stevehipwell commented on Nov 13, 2025

    @stevehipwell
    Collaborator

    @acouvreur is there a reason you can't use the Mutable Identities field?

  6. acouvreur commented on Nov 13, 2025

    @acouvreur
    ContributorAuthor

    @acouvreur is there a reason you can't use the Mutable Identities field?

    I was not aware of it! I'll take a look into it

  7. added this to the milestone on Nov 20, 2025
  8. modified the milestones: , v6.11.0 Release on Feb 2, 2026
  9. deiga commented on Feb 2, 2026

    @deiga
    Collaborator

    @stevehipwell Would your PR #3068 be solving this issue?

  10. stevehipwell commented on Feb 2, 2026

    @stevehipwell
    Collaborator

    @stevehipwell Would your PR #3068 be solving this issue?

    @deiga yes.

  11. acouvreur commented on Feb 11, 2026

    @acouvreur
    ContributorAuthor

    @stevehipwell Would your PR #3068 be solving this issue?

    @deiga yes.

    Are you sure ?

    The expected fix is that the github_repository_collaborators resource should be the repository ID instead of the repository name.

    Currently we have the following issue by having the repository name as ID:

    Consider that a repository name was just changed.

    resource "github_repository_collaborators.collaborators["the-repo-id"] must be replaced
    id = "the-old-repo-name" -> (known after apply)
    repository = "old-repo-name" -> "new-repo-name" # forces replacement
    ...

    This forces the deletion and then recreate the collaborators for the same repository.

    This creates a lot of churns, the resource cannot be cleaned up.

  12. deiga commented on Feb 11, 2026

    @deiga
    Collaborator

    @acouvreur We've built up the pattern of how renaming works best for the resources. The gist of it is: use repo name ad the configuration variable, but carry a computed repo ID inside the resource. If name changes, but ID doesn't => rename, not recreating

  13. acouvreur commented on Feb 17, 2026

    @acouvreur
    ContributorAuthor

    @acouvreur We've built up the pattern of how renaming works best for the resources. The gist of it is: use repo name ad the configuration variable, but carry a computed repo ID inside the resource. If name changes, but ID doesn't => rename, not recreating

    I think that makes sense, this should be the default for all resources.

    Use the GitHub API input which uses the resources name, but store the database ID to detect if the resource was renamed.

  14. stevehipwell commented on Feb 18, 2026

    @stevehipwell
    Collaborator

    @acouvreur in the case of the github_repository_collaborators resource the resource ID should be the repository ID as it has a 1-to-1 mapping to a GH entity with a global ID. We'll still be adding a computed repository_id so we don't recreate the resource on a rename as part of #3068 (or I may break those changes up into smaller PRs).

  15. acouvreur commented on Feb 24, 2026

    @acouvreur
    ContributorAuthor

    @acouvreur in the case of the github_repository_collaborators resource the resource ID should be the repository ID as it has a 1-to-1 mapping to a GH entity with a global ID. We'll still be adding a computed repository_id so we don't recreate the resource on a rename as part of #3068 (or I may break those changes up into smaller PRs).

    Perfect! @stevehipwell is there anything I can do to help you merge this feature ?

  16. stevehipwell commented on Feb 26, 2026

    @stevehipwell
    Collaborator

    @acouvreur do you want to take a look at #3233?

  17. removed
    Status: Triage
    on Feb 27, 2026
  18. added this to the v6.12.0 Release milestone on Feb 27, 2026
  19. moved this from In Progress to Done in Terraform Provideron Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions