-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github_repository_collaborator broken since v2.8.0 #469
Comments
hi @tpatzig, thank you for writing up this issue! |
Experimentation confirms identical API calls between the two versions. v2.8.0
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: 2020/05/30 09:55:03 [DEBUG] Creating repository collaborator: jcudit (terraformtesting/collaboration)
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: 2020/05/30 09:55:03 [DEBUG] Github API Request Details:
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: ---[ REQUEST ]---------------------------------------
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: PUT /repos/terraformtesting/collaboration/collaborators/jcudit HTTP/1.1
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Host: api.github.com
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: User-Agent: go-github
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Content-Length: 22
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Accept: application/vnd.github.v3+json
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Content-Type: application/json
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Accept-Encoding: gzip
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4:
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: {
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: "permission": "pull"
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: }
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4:
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: -----------------------------------------------------
2020-05-30T09:55:03.036-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: 2020/05/30 09:55:03 [TRACE] Acquiring lock for GitHub API request (%!q(<nil>))
2020-05-30T09:55:03.247-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: 2020/05/30 09:55:03 [TRACE] Releasing lock for GitHub API request (%!q(<nil>))
2020-05-30T09:55:03.247-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: 2020/05/30 09:55:03 [DEBUG] Github API Response Details:
2020-05-30T09:55:03.247-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: ---[ RESPONSE ]--------------------------------------
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: HTTP/1.1 204 No Content
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Content-Length: 0
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Access-Control-Allow-Origin: *
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Content-Security-Policy: default-src 'none'
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Date: Sat, 30 May 2020 13:55:03 GMT
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Server: GitHub.com
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Status: 204 No Content
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: Vary: Accept-Encoding, Accept, X-Requested-With
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Accepted-Oauth-Scopes:
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Content-Type-Options: nosniff
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Frame-Options: deny
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Github-Media-Type: github.v3; format=json
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Github-Request-Id: C931:63D2:16DF73:421DBD:5ED265B7
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Oauth-Scopes: admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, repo, user
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Ratelimit-Limit: 5000
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Ratelimit-Remaining: 4922
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Ratelimit-Reset: 1590847556
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: X-Xss-Protection: 1; mode=block
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4:
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4:
2020-05-30T09:55:03.248-0400 [DEBUG] plugin.terraform-provider-github_v2.8.0_x4: -----------------------------------------------------
2020/05/30 09:55:03 [DEBUG] github_repository_collaborator.jcudit: apply errored, but we're indicating that via the Error pointer rather than returning it: User jcudit is already a collaborator
2020/05/30 09:55:03 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: User jcudit is already a collaborator
2020/05/30 09:55:03 [ERROR] <root>: eval: *terraform.EvalSequence, err: User jcudit is already a collaborator
Error: User jcudit is already a collaborator v2.7.0
|
Looks like we released a change in how we interpret a @tpatzig from a user perspective, would you rather we emit a warning in this scenario instead of failing the run with an error? |
@jcudit I ran into the same problem under different circumstances over in #480 and I would rather expect a warning than an error. In my case the user was an organizational admin and got admin permissions automatically for the repository (check via the |
Hi @anGie44, the collaborator I'm trying to add is an outside the organization collaborator. Hi @jcudit, I do not see, why this should fail or error at all 🤷♂️ |
@tpatzig by |
I also did some more testing on this one today. My organization also has |
Yes, with outside collaborator I mean a gh user, that is not part of the organisation (nor in any of the organisations teams) by intention. The |
Edit: If you want the short version, @jcudit wrote it up here. My take is that the GitHub API documentation is incomplete and 204 should be accepted as an I was able to reproduce the issue with Terraform 0.12.26 Test
Result
Additional test
Additional Result
My understanding is that GitHub reports back with a 204 to every command and that is considered an error in Terraform: https://github.com/terraform-providers/terraform-provider-github/blob/master/github/resource_github_repository_collaborator.go#L77 Troubleshooting details
What the API documentation fails to mention (at least in my case), is that if a user is a member of my organization, the user will not need an invitation to be added as a collaborator to a repository within the organization. So, my assumption is that since the user doesn't need an invite, a 201 response would be inappropriate. The only other defined response is 204 and for whatever reason, GitHub API chooses to send that in each In short: the GitHub API documentation fails to mention that 204 is reported in any regular case. What's worse, it seems to execute the request properly, before reporting 204, even when the user is really a collaborator on the repo. Additional note: the call to GitHub AddCollaborator seems fine. Proposed solution
|
Personally, I'd prefer never erring and only giving warnings. If I have a user that has access to the repo already (say through a team), but we want to give this single user (not the whole team) more access, I'd want to be able to do that through the |
I'm running into this issue now on provider v2.19. |
I also have this issue with repo collaborators that are managed by Terraform via this provider. If you then import the resource into the state and rerun the plan the infra is up to date and not changes are detected. |
Even though this is now closed with a fix, we are still experiencing the issue with Terraform version v0.12.25 We have to revert to Provider version 2.7.0 to get rid of the error. |
Hi @victor-wong-dragon, apologies for the confusion! the PR #525, while merged, hasn't released with a recent version of the provider. I just updated the PR with the |
Hello @anGie44 can we release the 2.9.3 version with this bugfix before 3.0.0? |
Since github provider v2.8.0 the
github_repository_collaborator
resource is broken.It fails with
User <username> is already a collaborator
. In v2.7.0 this worked as expected.Terraform Version
v0.12.25
Affected Resource(s)
Terraform Configuration Files
Panic Output
Expected Behavior
What should have happened?
The collaborator should be added to the repository and the resource should be in the state.
Actual Behavior
What actually happened?
The collaborator gets added to the repository with the correct permissions,
but terraform fails with this error and the resource is not in the state.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: