terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

[BUG]: Changes are not being detected on github_repository

Open tekumara opened this issue 7 months ago • 1 comments

Expected Behavior

During terraform plan the provider should show changes between my github repo and the terraform config.

Actual Behavior

When trying to update allow_rebase_merge, and allow_squash_merge on my repo, the provider is not detecting any changes.

The config:

  allow_merge_commit = true
  allow_squash_merge = false

Terraform state matches config:

❯ terraform state pull | jq '.resources[151].instances[0].attributes | {allow_merge_commit, allow_squash_merge, etag}'
{
  "allow_merge_commit": true,
  "allow_squash_merge": false,
  "etag": "W/\"79cc48f62fa91f6490cdf4ea43586e597d00aaaba67ea52f2382c7785d8d1a5e\""
}

But the resource itself looks like this when accessed via the API:

❯ gh api /repos/tekumara/baps-model-template | jq '{allow_merge_commit, allow_squash_merge}'
{
  "allow_merge_commit": false,
  "allow_squash_merge": true
}

Note that the etag on the actual resources matches the state etag:

❯ gh api --verbose /repos/tekumara/baps-model-template | grep 'Etag:'
< Etag: W/"79cc48f62fa91f6490cdf4ea43586e597d00aaaba67ea52f2382c7785d8d1a5e"

I'm not sure how the terraform state ended up with the correct etag, but the wrong values for allow_merge_commit and allow_squash_merge.

Terraform Version

❯ terraform --version Terraform v1.11.4 on darwin_arm64

  • provider registry.terraform.io/hashicorp/aws v5.96.0
  • provider registry.terraform.io/integrations/github v6.6.0

Affected Resource(s)

github_repository

Terraform Configuration Files


Steps to Reproduce

No response

Debug Output


Panic Output


Code of Conduct

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

tekumara avatar May 02 '25 00:05 tekumara

NB: Etag appears to be based on the content of the github response and stable across time for the same set of response values.

tekumara avatar May 02 '25 10:05 tekumara