Skip to content

[BUG]: github_team_repository error with version 5.9.0 - fails with at least one permission expected from permissions map #1373

Closed

Description

@jai

Terraform Version

1.3.3

Affected Resource(s)

  • github_team_repository

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "github_team_repository" "push_access" {
  for_each   = toset(var.push_access_team_ids)
  repository = github_repository.repository.id
  team_id    = each.value
  permission = "push"
}

Debug Output

[PENDING]
Please provide a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

N/A

Expected Behavior

Access should be refreshed, changes should be proposed by terraform plan

Actual Behavior

terraform plan errors:

╷
│ Error: at least one permission expected from permissions map
│ 
│   with module.easyhotel_docker_compose_repository.github_team_repository.push_access["6845313"],
│   on modules/easyhotel_github_repository/main.tf line 34, in resource "github_team_repository" "push_access":
│   34: resource "github_team_repository" "push_access" {
│ 
╵

Steps to Reproduce

With existing repo/permissions

  • terraform plan will fail with above error

With non-existing permissions (permissions need to be created by this terraform run)

  • terraform apply will create the permission/s above (verified that access was given by checking the GitHub web UI), but the apply will still fail with the same error above.

Important Factoids

Is there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Similar error messages (not the same cause I guess):

Activity

  1. changed the title [-][BUG]: `github_team_repository` error with version 5.9.0[/-] [+][BUG]: `github_team_repository` error with version 5.9.0 - fails with `at least one permission expected from permissions map`[/+] on Nov 19, 2022
  2. dmitry-mightydevops commented on Nov 19, 2022

    @dmitry-mightydevops

    Same thing.

    Terraform fails with API call, but the actual team's permission is added, I can see it in the gui.

    Debug log:

    ✗  terraform version                                                                                  
    Terraform v1.3.4
    on linux_amd64
    
    
    022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 2022/11/18 21:51:39 [DEBUG] Github API Request Details:
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: ---[ REQUEST ]---------------------------------------
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: GET /organizations/11111111/team/2222222/repos/team-nest/team-backend HTTP/1.1
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Host: api.github.com
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: User-Agent: go-github/v48.0.0
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Accept: application/vnd.github.stone-crop-preview+json
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Accept-Encoding: gzip
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 
    2022-11-18T21:51:39.392-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: -----------------------------------------------------
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 2022/11/18 21:51:39 [DEBUG] Github API Response Details:
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: ---[ RESPONSE ]--------------------------------------
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: HTTP/2.0 204 No Content
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Access-Control-Allow-Origin: *
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Content-Security-Policy: default-src 'none'
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Date: Sat, 19 Nov 2022 03:51:39 GMT
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Server: GitHub.com
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: Vary: Accept-Encoding, Accept, X-Requested-With
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Content-Type-Options: nosniff
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Frame-Options: deny
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Github-Media-Type: github.stone-crop-preview; format=json
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Github-Request-Id: 9BB6:09B3:4B1B1D:9AE311:637852C9
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Ratelimit-Limit: 12500
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Ratelimit-Remaining: 11289
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Ratelimit-Reset: 1668830354
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Ratelimit-Resource: core
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Ratelimit-Used: 1211
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: X-Xss-Protection: 0
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: 
    2022-11-18T21:51:39.622-0600 [DEBUG] provider.terraform-provider-github_v5.9.0: -----------------------------------------------------
    2022-11-18T21:51:39.622-0600 [ERROR] vertex "github_team_repository.backend" error: at least one permission expected from permissions map
    2022-11-18T21:51:39.622-0600 [ERROR] vertex "github_team_repository.backend (expand)" error: at least one permission expected from permissions map
    ╷
    │ Warning: Resource targeting is in effect
    │ 
    │ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
    │ 
    │ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
    ╵
    ╷
    │ Error: at least one permission expected from permissions map
    │ 
    │   with github_team_repository.backend,
    │   on project-backend.tf line 77, in resource "github_team_repository" "backend":
    │   77: resource "github_team_repository" "backend" {
    │ 
    ╵
    2022-11-18T21:51:39.851-0600 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
    2022-11-18T21:51:39.857-0600 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/integrations/github/5.9.0/linux_amd64/terraform-provider-github_v5.9.0 pid=2167833
    2022-11-18T21:51:39.857-0600 [DEBUG] provider: plugin exited
    make: *** [Makefile:54: apply] Error 1

    terraform code creates repo, but then immediately fails with the error above

    resource "github_team_repository" "backend" {
      team_id    = module.github.github_team_id
      repository = module.github_repository_backend.id
      permission = "maintain"
    
      depends_on = [module.client, module.github, module.backend]
    }
  3. ivorsmorenburg commented on Nov 19, 2022

    @ivorsmorenburg

    Broken, I get the same error testing out same TF and the new GitHub version released 5.9.0

  4. oprudkyi commented on Nov 20, 2022

    @oprudkyi

    workaround

    terraform {
      required_providers {
        github = {
          source  = "integrations/github"
          version = "!= 5.9.0"
        }
      }
    }
    
  5. jhaumont commented on Nov 21, 2022

    @jhaumont

    Same here. This one + the issue with visibility broken, it's all broken on our side 😄

  6. jhaumont commented on Nov 21, 2022

    @jhaumont

    An interesting thing.
    With this request (it is a similar one to what we have in 5.9.0):

    curl \
      -H "Accept: application/vnd.github.stone-crop-preview+json" \
      -H "Authorization: Bearer ${GITHUB_TOKEN}" \
      https://api.github.com/orgs/myorg/teams/myteam/repos/myorg/myreponame

    You have no result.

    But with this one (it is a similar one to what we have in 5.8.0):

    curl \
      -H "Accept: application/vnd.github.v3.repository+json" \
      -H "Authorization: Bearer ${GITHUB_TOKEN}" \
      https://api.github.com/orgs/myorg/teams/myteam/repos/myorg/myreponame

    You have the result!

    The difference comes from the Accept header: vnd.github.v3.repository+json (working) instead of vnd.github.stone-crop-preview+json (not working)
    I don't understand why this header is used as the default one is correct

    headers := []string{mediaTypeOrgPermissionRepo}

    cc @nickfloyd @kfcampbell

  7. scruplelesswizard commented on Nov 21, 2022

    @scruplelesswizard

    Thanks for chasing this down @jhaumont!

    The difference comes from the Accept header: vnd.github.v3.repository+json (working) instead of vnd.github.stone-crop-preview+json (not working)
    I don't understand why this header is used as the default one is correct

    stone-crop-preview is for the Team Review Assignments preview from the docs.

    The change landed in #1356, specifically in 934f06a

  8. david-bain commented on Nov 22, 2022

    @david-bain
    Contributor

    We also are seeing this exact issue. Thanks for finding the issue @jhaumont.
    Is this able to be reverted as soon as possible please? I need the other features of 5.8.0 and 5.9.0.

  9. jai commented on Nov 22, 2022

    @jai
    Author

    @chaosaffe what's the correct way of dealing with this? Reverting the entire commit takes away a whole feature, but commenting code out as in #1378 doesn't seem great to me either.

  10. jhaumont commented on Nov 22, 2022

    @jhaumont

    @chaosaffe what's the correct way of dealing with this? Reverting the entire commit takes away a whole feature, but commenting code out as in #1378 doesn't seem great to me either.

    I prefer a real fix but I don't have the time to do it. I let the maintainers decide!

  11. cfisher281 commented on Nov 22, 2022

    @cfisher281

    Any idea when we can get this fix implemented. Also thank you @jhaumont for digging into all of this and finding a resolution.

  12. added
    Status: Up for grabs
    Status: Triage
    on Nov 22, 2022
  13. 4 remaining items

  14. jhaumont commented on Nov 23, 2022

    @jhaumont

    @nickfloyd #1382 is a stab at fixing this in a way that doesn't break the new feature that was added

    I ve closed my PR ! Thx for the fix @mpoindexter

  15. RoozbehShafiee commented on Nov 23, 2022

    @RoozbehShafiee

    5.9.1 didn't work for me. same output:

    Error: at least one permission expected from permissions map
    
  16. fosterm-mw commented on Nov 23, 2022

    @fosterm-mw

    5.9.1 Does not work for me as well. What's weird is changing the version in the github provider block did not fix the issue for my workspace.

  17. fatbasstard commented on Nov 25, 2022

    @fatbasstard
    Contributor

    Still hitting this issue in the 5.9.1

  18. elliottpope commented on Nov 25, 2022

    @elliottpope
    Contributor

    There's a fix for the issue in #1384. Confirmed the acceptance tests for github_team_repository pass after introducing this change

  19. nickfloyd commented on Nov 28, 2022

    @nickfloyd
    Contributor
  20. laurenchurch commented on Nov 28, 2022

    @laurenchurch

    Still hitting this issue in 5.9.2 for the github_team resource.

  21. Tenzer commented on Nov 28, 2022

    @Tenzer

    It works for me with 5.9.2. We are using github_team_repository.

  22. lukas-hetzenecker commented on Nov 28, 2022

    @lukas-hetzenecker

    Everything working here again perfectly with 5.9.2, using github_team and github_team_repository. Thanks for the bugfix! ❤️

  23. Nexus357ZA commented on Nov 28, 2022

    @Nexus357ZA

    I'm still having this issue with the github_team_repository resource 5.9.2

  24. RoozbehShafiee commented on Nov 29, 2022

    @RoozbehShafiee

    The 5.9.2 works for me too. Thanks for the bug fix.

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

    Status: TriageStatus: Up for grabs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions