You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
github_repository_collaborator unable to validate triage and maintain permissions #480
After importing an existing collaborator with Maintain permissions the collaborator should have maintain permissions in the state.
Actual Behavior
After importing an existing collaborator with Maintain permissions the collaborator gets push permissions in the state. Running terraform plan afterwards notes a replacement.
# github_repository_collaborator.my-repo-test-user must be replaced
-/+ resource "github_repository_collaborator" "my-repo-test-user" {
~ id = "my-repo:testuser" -> (known after apply)
+ invitation_id = (known after apply)
~ permission = "push" -> "maintain" # forces replacement
repository = "my-repo"
username = "testuser"
}
Running terraform apply in the end leads to
Error: User testuser is already a collaborator
Overall, the error is similar to #469, but the actual problem seems to be the import to the state in this situation.
hi @HorizonNet, thanks for writing-up this issue! I was able to reproduce and looking into this more, I think we're bound by the limitations of the github API (atleast in v3...in v4 I'm able to retrieve the "maintain" permissions for my user from the GraphQL explorer), such that the permission levels provided on request to create a github collaborator are not always equal to the permission levels returned from the github API.
while an invitation to collaborate in a repository can be read(aka pull in this provider), write (aka push in this provider), maintain, triage, or admin (and the invite's permission level can be read correctly with the List API call), once that user accepts that invitation (like in the case you've presented), the permission levels we can read from the github API (using the List Collaborators endpoint as done here in the provider) are only push, pull, or admin. thus, I believe we'll perpetually get this diff in cases where the intended permission is either maintain or triage. it's as if there's not a 1:1 mapping of repository invitation permission level to repository permission level from the github API's perspective.
with this being said, perhaps one way to suppress this diff will be to apply a DiffSuppressFunc to the permission attribute in the github_repository_collaborator resource? but only for these 2 permissions (maintain and triage) such that at terraform plan time, if the permission value determined from the Github API is push while we expected maintain or pull when we expected triage, then the diff will be suppressed, and a non-empty plan will be returned.
hmm this issue also seems to bring up something we can further validate in the acceptance tests such that atm we're validating the cases where we invite a new collaborator and check against the invite's permissions (which can contain push, pull, maintain, triage, or admin), but we haven't simulated cases where a user accepts the invite and then refresh a plan accordingly @jcudit
I also check the collaborators endpoints for v3 and I also see an easy way to distinguish someone with Write permissions from someone with Maintain permissions. Are there any plans already for moving to v4?
This is something I've also run into. Very similar thing. Terraform wants to reapply this change every time, even though the user already has maintain access to the repository.
# module.repository.github_repository_collaborator.users["example-user"] must be replaced
-/+ resource "github_repository_collaborator" "users" {
~ id = "repository:example-user" -> (known after apply)
+ invitation_id = (known after apply)
~ permission = "push" -> "maintain" # forces replacement
repository = "repository"
username = "example-user"
}
The GitHub REST API is limiting us to only validating pull, push and admin 😢
The GraphQL API currently has no workarounds available for querying triage and maintain 😢
The interactive nature of this resource limits our testing 😢
Open to adding diff suppression here if that helps while we wait for a better API to become available. Aiming to get something up for review targeting our next release.
changed the title [-]github_repository_collaborator imports wrong state[/-][+]github_repository_collaborator unable to validate `triage` and `maintain` permissions[/+]on Jan 29, 2021
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
Activity
anGie44 commentedon Jun 1, 2020
hi @HorizonNet, thanks for writing-up this issue! I was able to reproduce and looking into this more, I think we're bound by the limitations of the github API (atleast in v3...in v4 I'm able to retrieve the "maintain" permissions for my user from the GraphQL explorer), such that the permission levels provided on request to create a github collaborator are not always equal to the permission levels returned from the github API.
while an invitation to collaborate in a repository can be
read(aka pull in this provider), write (aka push in this provider), maintain, triage, or admin(and the invite's permission level can be read correctly with the List API call), once that user accepts that invitation (like in the case you've presented), the permission levels we can read from the github API (using the List Collaborators endpoint as done here in the provider) are onlypush, pull, or admin. thus, I believe we'll perpetually get this diff in cases where the intended permission is eithermaintain or triage. it's as if there's not a 1:1 mapping of repository invitation permission level to repository permission level from the github API's perspective.with this being said, perhaps one way to suppress this diff will be to apply a
DiffSuppressFuncto thepermissionattribute in thegithub_repository_collaboratorresource? but only for these 2 permissions (maintain and triage) such that atterraform plantime, if the permission value determined from the Github API ispushwhile we expectedmaintainorpullwhen we expectedtriage, then the diff will be suppressed, and a non-empty plan will be returned.anGie44 commentedon Jun 1, 2020
hmm this issue also seems to bring up something we can further validate in the acceptance tests such that atm we're validating the cases where we invite a new collaborator and check against the invite's permissions (which can contain
push, pull, maintain, triage, or admin), but we haven't simulated cases where a user accepts the invite and then refresh a plan accordingly @jcuditHorizonNet commentedon Jun 1, 2020
I also check the collaborators endpoints for v3 and I also see an easy way to distinguish someone with
Writepermissions from someone withMaintainpermissions. Are there any plans already for moving to v4?HorizonNet commentedon Jun 4, 2020
Ah, just saw the discussion over in #83.
emmahsax commentedon Aug 7, 2020
This is something I've also run into. Very similar thing. Terraform wants to reapply this change every time, even though the user already has
maintainaccess to the repository.bharathkkb commentedon Nov 20, 2020
I am also getting a diff with
triage. User does havetriageaccess to repo.nick-hf commentedon Dec 18, 2020
This problem still makes every single one of our plans so noisy :(
jcudit commentedon Jan 29, 2021
Took another pass at this and agree that:
pull,pushandadmin😢triageandmaintain😢Open to adding diff suppression here if that helps while we wait for a better API to become available. Aiming to get something up for review targeting our next release.
[-]github_repository_collaborator imports wrong state[/-][+]github_repository_collaborator unable to validate `triage` and `maintain` permissions[/+]jcudit commentedon Jan 29, 2021
☝🏾 could use some 👀 for anyone watching this.
Change "maintain" to "push" in collaborations
github-actions commentedon Dec 9, 2022
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!github-actions commentedon Apr 24, 2024
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!