Skip to content

[BUG]: github_repository_webhook wrongfully identifies org repos as user repos after 6.9.0 #3042

@8fuhst

Description

@8fuhst

Expected Behavior

The terraform provider creates a webhook for the passed repository.

Expected URL should be something like: https://api.github.com/repos/ORGANIZATION/REPO/hooks

Actual Behavior

The url is constructed incorrectly, with the current user being injected into it, instead of only the organization.

Actual URL is something like: https://api.github.com/repos/LOCAL-USER/ORGANIZATION/REPO/hooks, which 404's as LOCAL-USER does not own the actual repository.

Terraform Version

OpenTofu v1.10.7
Github Provider Version (integrations/github) v6.9.0, rolling back to v6.8.3 fixes the issue for now

Affected Resource(s)

  • github_repository_webhook

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source = "integrations/github"
    }
  }
}

provider "github" {
  token = ***
  owner = "OWNER"
}

resource "github_repository_webhook" "webhook" {

  repository = "ORGANIZATION/REPO"

  configuration {
    url          = URL
    secret       = ***
    content_type = "json"

  active = true
  events = var.events
  }

Steps to Reproduce

  1. Create organizational repository
  2. Create token for user with org access
  3. Authenticate using e.g. GH CLI
  4. Create a github_repository_webhook resource for the org repo
  5. terraform apply

Debug Output

* Failed to execute "tofu apply" in ./.terragrunt-cache/5xbDhd0o58dlc-OW65wpCtUfrxc/TYx-cNMOLlc0h6FEuz8-jExTYNQ
  ╷
  │ Error: POST https://api.github.com/repos/USER/ORGANIZATION/WEBHOOK_NAME/hooks: 404 Not Found []
  │ 
  │   with MODULE.github_repository_webhook.WEBHOOK_NAME[0],
  │   on .terraform/modules/MODULE/main.tf line 127, in resource "github_repository_webhook" "WEBHOOK_NAME":
  │  127: resource "github_repository_webhook" "WEBHOOK_NAME" {
  │ 
  ╵
  
  exit status 1

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions