integrations / integrations/terraform-provider-github

[BUG]: github_repository reports drift on merge_commit_message and merge_commit_title if allow_merge_commit is false

Open
#3,554 2 comments 0 reactions 0 assignees View on GitHub
r/repository Status: Triage Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

When `allow_merge_commit = false` in `github_repository` I would expect the values of `merge_commit_title` and `merge_commit_message` to be ignored as they can't be changed if merge commits are disabled.

### Actual Behavior

I had the following settings applied

```
allow_merge_commits = true
merge_commit_message = "PR_BODY"
merge_commit_title = "PR_TITLE"
```

then when I flipped `allow_merge_commmits = false`

```
allow_merge_commits = true
merge_commit_message = "PR_BODY"
merge_commit_title = "PR_TITLE"
```
and applied that.

Now if I plan again I get the following drift:

```
! merge_commit_message = "PR_TITLE" -> "PR_BODY"
! merge_commit_title = "MERGE_MESSAGE" -> "PR_TITLE"
```

### Terraform Version

Terraform v1.15.8
on linux_arm64
+ provider registry.terraform.io/hashicorp/google v7.38.0
+ provider registry.terraform.io/integrations/github v6.12.1

### GitHub Installation Type

- [ ] GitHub.com (Free, Pro, or Team)
- [ ] GitHub Enterprise Server (on-premises)
- [ ] GitHub Enterprise Cloud with Personal Accounts (github.com)
- [ ] GitHub Enterprise Cloud with Managed Users/EMU (github.com)
- [ ] GitHub Enterprise Cloud with Data Residency (*.ghe.com)
- [x] I don't know

### Affected Resource(s)

- github_repository

### Terraform Configuration Files

```hcl

```

### Steps to Reproduce

I can't copy my actual terraform configuration here, but I think this is the gist of it

terraform config
```
resource "github_repository" "this" {
name = "test"
description = ""
delete_branch_on_merge = true
auto_init = true
allow_update_branch = true
allow_merge_commit = true
allow_rebase_merge = true
allow_squash_merge = true
squash_merge_commit_title = "PR_TITLE"
squash_merge_commit_message = "PR_BODY"
merge_commit_title = "PR_TITLE"
merge_commit_message = "PR_BODY"

}

```

terraform plan & apply that.

Then change `allow_merge_commit = false`

terraform plan & apply that (it will work fine).

Then `terraform plan` again, it will show drift in `merge_commit_title` and `merge_commit_message`:

```
resource "github_repository" "this" {
id = "xxxxx"
! merge_commit_message = "PR_TITLE" -> "PR_BODY"
! merge_commit_title = "MERGE_MESSAGE" -> "PR_TITLE"
name = "xxxx"
# (40 unchanged attributes hidden)

# (1 unchanged block hidden)
}
```

So it believes that current value of `merge_commit_message = PR_TITLE` which I guess it the GitHub defaults ( GitHub repo > Settings > General > Pull Requests > Allow merge commits > Default message will set `merge_commit_title: "MERGE_MESSAGE", merge_commit_message: "PR_TITLE"`)

### Debug Output

```shell

```

### Code of Conduct

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

Contributor guide

Open the contributing guide

Research direction

Start at the github_repository resource entry point and reproduce the reported plan/apply sequence with allow_merge_commit changed from true to false. Verify the provider ignores merge_commit_title and merge_commit_message when merge commits are disabled, and confirm a subsequent terraform plan reports no drift.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, go, terraform
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.