integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
879 stars 719 forks source link

[BUG]: github_repository_webhook inserts github username in api url #2173

Open tycen-tsn opened 5 months ago

tycen-tsn commented 5 months ago

Expected Behavior

github_repository_webhook would try to call https://api.github.com/repos/org/repo/hooks to create a webhook

Actual Behavior

terraform inserts my github username into the api url and errors out with a 404:

Error: POST https://api.github.com/repos/tycen-tsn/<org>/<repo>/hooks: 404 Not Found []
│ 
│   with github_repository_webhook.github_hook,
│   on webhooktest.tf line 1, in resource "github_repository_webhook" "github_hook":
│    1: resource "github_repository_webhook" "github_hook" {
│ 

I have tried numerous things for the repository to rule out anything being passed there. I even left repository blank ("") and the 404 error had the url: https://api.github.com/repos/tycen-tsn/hooks

I have ruled out auth issues by adding a data "github_repository" "repo" data call and it retrieves info about the repo. I have checked permissions on the personal access token and it has admin:repo_hook permissions.

Terraform Version

Terraform v1.7.4 + provider registry.terraform.io/integrations/github v6.0.0 (tried with v5.45.0 also) Also using Terragrunt version 0.55.10

Affected Resource(s)

Terraform Configuration Files

resource "github_repository_webhook" "github_hook" {
  repository    = "Org/repo"
  configuration {
    url          = "<aws codepipeline webhook url>"
    content_type = "json"
    insecure_ssl = false
    secret       = "<secret>"
  }

  events = ["push"]
}

Steps to Reproduce

terragrunt apply

Debug Output

Error: POST https://api.github.com/repos/tycen-tsn/<org>/<repo>/hooks: 404 Not Found []
│ 
│   with github_repository_webhook.github_hook,
│   on webhooktest.tf line 1, in resource "github_repository_webhook" "github_hook":
│    1: resource "github_repository_webhook" "github_hook" {

Panic Output

No response

Code of Conduct