Skip to content
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

[BUG]: Fix CanAdminsBypass to Environment #1804

Closed
1 task done
nirav-chotai opened this issue Jul 20, 2023 · 6 comments · Fixed by #2001
Closed
1 task done

[BUG]: Fix CanAdminsBypass to Environment #1804

nirav-chotai opened this issue Jul 20, 2023 · 6 comments · Fixed by #2001
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@nirav-chotai
Copy link

Describe the need

While using github_repository_environment, it is automatically taking can_admins_bypass and making invalid PUT request.

"message": "Invalid request.\n\n\"can_admins_bypass\" is not a permitted key.",

Example code:

resource "github_repository_environment" "dev" {
  for_each = toset(
    [
      "dev-demo"
    ]
  )
  repository  = each.key
  environment = "dev-demo"
  reviewers {
    teams = ["123"]
  }
  deployment_branch_policy {
    protected_branches     = true
    custom_branch_policies = false
  }
}

There is no field for can_admins_bypass here, plan is successful, but when apply runs, and making PUT request, below is DEBUG error

2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: ---[ REQUEST ]---------------------------------------
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: PUT /api/v3/repos/my/dev-demo/environments/dev-demo HTTP/1.1
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Host: abc.com
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: User-Agent: go-github/v53.2.0
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Content-Length: 167
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Accept: application/vnd.github.v3+json,application/vnd.github.stone-crop-preview+json
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Content-Type: application/json
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Github-Api-Version: 2022-11-28
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Accept-Encoding: gzip
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: {
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "wait_timer": 0,
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "reviewers": [
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:   {
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:    "type": "Team",
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:    "id": 123
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:   }
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  ],
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "can_admins_bypass": true,
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "deployment_branch_policy": {
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:   "protected_branches": true,
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:   "custom_branch_policies": false
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  }
2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: }

Because of can_admins_bypass in above request, getting below error:

2023-07-20T13:00:28.754-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: -----------------------------------------------------
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: 2023/07/20 13:00:29 [DEBUG] GitHub API Response Details:
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: ---[ RESPONSE ]--------------------------------------
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: HTTP/2.0 422 Unprocessable Entity
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Content-Length: 200
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Access-Control-Allow-Origin: *
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.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
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Content-Security-Policy: default-src 'none'
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Content-Type: application/json; charset=utf-8
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Date: Thu, 20 Jul 2023 20:00:29 GMT
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Server: github.com
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: Strict-Transport-Security: max-age=31536000; includeSubdomains
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Accepted-Oauth-Scopes:
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Content-Type-Options: nosniff
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Frame-Options: deny
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Github-Enterprise-Version: 3.8.4
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Github-Media-Type: github.v3; format=json, github.stone-crop-preview; format=json
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Github-Request-Id: 7c278f62-eb33-42d7-8291-fde2d9d3cf20
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Oauth-Scopes: admin:repo_hook, delete_repo, project, repo, user
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Ratelimit-Limit: 10000
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Ratelimit-Remaining: 9515
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Ratelimit-Reset: 1689884684
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Ratelimit-Resource: core
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Ratelimit-Used: 485
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Runtime-Rack: 0.102010
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: X-Xss-Protection: 0
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:
2023-07-20T13:00:29.088-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: {
2023-07-20T13:00:29.089-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "message": "Invalid request.\n\n\"can_admins_bypass\" is not a permitted key.",
2023-07-20T13:00:29.089-0700 [DEBUG] provider.terraform-provider-github_v5.31.0:  "documentation_url": "https://docs.github.com/enterprise-server@3.8/rest/reference/repos#create-or-update-an-environment"
2023-07-20T13:00:29.089-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: }
2023-07-20T13:00:29.089-0700 [DEBUG] provider.terraform-provider-github_v5.31.0: -----------------------------------------------------

SDK Version

terraform-provider-github_v5.31.0

API Version

v3.8.4

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nirav-chotai nirav-chotai added Status: Triage This is being looked at and prioritized Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR labels Jul 20, 2023
@kfcampbell kfcampbell added Type: Bug Something isn't working as documented Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR labels Jul 24, 2023
@kfcampbell kfcampbell moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Jul 24, 2023
@enricojonas
Copy link

Hitting the same issue - it seems that this feature is implemented in API 3.9+ though I couldn't find it in the API docs, there is something mentioned in the release notes (https://docs.github.com/enterprise-server@3.9/admin/release-notes#3.9.0) about this bypassing.

It's really annoying that we hit this kind of issues now and then with GHES. We are also on 3.8.4.

Found the PR here actually: google/go-github#2721

In the corresponding issue (google/go-github#2722) it is even mentioned that it is not included in the documentation as this is a fairly new feature. Shouldn't the docs be updated together with the feature implementation?!

@BehbudSh
Copy link

BehbudSh commented Aug 1, 2023

Is there any update on this issue?

@scott-doyland-burrows
Copy link
Contributor

scott-doyland-burrows commented Nov 4, 2023

I also wanted to use this feature so have setup this PR for it:

#2001

@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Nov 21, 2023
@VOVELEE
Copy link

VOVELEE commented Nov 30, 2023

Does anyone know when this will be released :)

@emschu
Copy link

emschu commented Dec 20, 2023

It seems to be a "workaround" not providing a reviewers block in the github_repository_environment resource

@kfcampbell
Copy link
Member

I cut a release yesterday, this bugfix should be set to use!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
8 participants