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]: github_repository_webhooks #2440

Open
1 task done
faust64 opened this issue Oct 27, 2024 · 4 comments
Open
1 task done

[BUG]: github_repository_webhooks #2440

faust64 opened this issue Oct 27, 2024 · 4 comments
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@faust64
Copy link

faust64 commented Oct 27, 2024

Expected Behavior

Discovering webhooks from repositories (see configuration files), using github_repository_webhooks data source.

We used to get a response, including some .webhooks[].url key. That key was designating the URL, targeted by each webhook.
Dumping those .webhooks into a file, I would get lists, such as:

"terraform-repo1":
- "active": true
  "id": 1670862
  "name": "web"
  "type": "Repository"
  "url": "https://my-ci-webhook-receiver.example.com/"

Actual Behavior

Today, I realize that bit of code is broken. Debugging, I can now find the following to be returned by github_repository_webhooks:

"terraform-repo1":
- "active": true
  "id": 1670862
  "name": "web"
  "type": "Repository"
  "url": "https://github.example.com/api/v3/repos/kino/terraform-repo1/hooks/1670862"

Terraform Version

Terraform v1.9.5, linux amd64, provider registry.terraform.io/integrations/github v6.3.1

Affected Resource(s)

github_repository_webhooks data source

Terraform Configuration Files

data "github_repository_webhooks" "webhooks" {
  for_each   = local.collected_repos
  repository = each.key
}
locals {
  debug_ci_webhooks = {
    for repo_k, repo_v in local.collected_repos :
    repo_k => data.github_repository_webhooks.webhooks[repo_k].webhooks
  }
}
resource "local_file" "webhooks" {
  filename = "${path.root}/debug/existing_webhooks.yml"
  content  = yamlencode(local.debug_ci_webhooks)
}

Steps to Reproduce

unclear.
I know my colleagues recently upgraded from GHE 3.11.13 to 3.13.5
While our upgrade to 3.11.13 is recent as well... I'm not sure why I last saw that code working, could very well be with a 3.9

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@faust64 faust64 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Oct 27, 2024
@faust64
Copy link
Author

faust64 commented Oct 27, 2024

Additional notes, as I'm now checking GitHub API directly:

$> curl --header "Authorization ..." https://github.example.com/api/v3/repos/my-org/my-repo/hooks
[
  {
    "type": "Repository",
    "id": 1659968,
    "name": "web",
    "active": true,
    "events": [
      "*"
    ],
    "config": {
      "content_type": "json",
      "insecure_ssl": "0",
      "secret": "********",
      "url": "https://my-ci-webhooks-receiver/"
    },
    "updated_at": "2024-03-01T08:51:32Z",
    "created_at": "2024-03-01T08:51:32Z",
    "url": "https://github.example.com/api/v3/repos/my-org/my-repoi/hooks/1659968",
    "test_url": "https://github.example.com/api/v3/repos/my-org/my-repo/hooks/1659968/test",
    "ping_url": "https://github.example.com/api/v3/repos/my-org/my-repo/hooks/1659968/pings",
...

So ... It should be there ... at least still returned by API.

Also note:
Instead of extracting .webhooks[].url, I tried to extract webhooks[].configuration.url -- that seems to be the format, for github_repository_webhook resource ... but it looks like the data source does not have this. Only that .url.

@faust64
Copy link
Author

faust64 commented Oct 30, 2024

Wasn't there a mistake here? That one looks wrong, doesn't it?!

d3784bd#diff-87481a16ab9a0f8469b24b0d44496c11596a0a28152b7aac21257b8d9a6ab00eL103

Checking diffs on go-github, in between v57 and v62, there's that' commit:
google/go-github@7342217#diff-2eabe526c1730373103929313b86d4a71b558b8a154d77827f2fc060719d0ef9

I'm not well versed in Go ... But I would say Config's still there, now using some HookConfig struct ... There should still be a way to access that config url? While that hook.URL used as a replacement ...might have been there already. It's not the URL we're expecting there. Is it?

@faust64
Copy link
Author

faust64 commented Oct 30, 2024

... Maybe a question to @EttoreFoti? Since you worked on that diff I'm looking at ... What do you think?

@faust64
Copy link
Author

faust64 commented Oct 30, 2024

... maybe not: trying to downgrade provider to 6.3.0 or 6.2.3, I still observe the same ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

1 participant