Expected Behavior
No diff when running tofu plan with a GITHUB_TOKEN that cannot read (squash or rebase) merge settings,1 similar to how vulnerability_alerts was fixed in #3144.
Actual Behavior
tofu plan reports changes for merge_commit_message, merge_commit_title, squash_merge_commit_message, and squash_merge_commit_title on every run.
Perhaps the provider cannot read these fields with an unprivileged token, so it gets null. It then compares those unknown values against the config and plans to set them to provider default (PR_TITLE, MERGE_MESSAGE, etc.).
Terraform Version
OpenTofu
integrations/github v6.11.1
Affected Resource(s)
Terraform Configuration Files
import {
id = "amber-script-action"
to = github_repository.this
}
resource "github_repository" "this" {
allow_merge_commit = false
allow_squash_merge = false
merge_commit_message = null
merge_commit_title = null
squash_merge_commit_message = null
squash_merge_commit_title = null
# ...
}
The full code: https://github.com/lens0021/amber-script-action/blob/dca2d0e3ee1d4cebcf50287e43c8894a72d9f10a/.github/tf/repository.tf
Steps to Reproduce
- Use a
GITHUB_TOKEN with only Contents: read, Metadata: read.
- Run
tofu plan.
- Plan shows changes.
The full code: https://github.com/lens0021/amber-script-action/blob/dca2d0e3ee1d4cebcf50287e43c8894a72d9f10a/.github/workflows/tf.yaml#L22-L39
Debug Output
##[debug]Set output stdout = github_repository.this: Preparing import... [id=amber-script-action]
##[debug]github_repository.this: Refreshing state... [id=amber-script-action]
##[debug]github_repository_ruleset.default: Preparing import... [id=amber-script-action:6070737]
##[debug]github_repository_ruleset.default: Refreshing state... [id=6070737]
##[debug]
##[debug]OpenTofu used the selected providers to generate the following execution
##[debug]plan. Resource actions are indicated with the following symbols:
##[debug] ~ update in-place (current -> planned)
##[debug]
##[debug]OpenTofu will perform the following actions:
##[debug]
##[debug] # github_repository.this will be updated in-place
##[debug] # (imported from "amber-script-action")
##[debug] ~ resource "github_repository" "this" {
##[debug] allow_auto_merge = false
...
Panic Output
Code of Conduct
Expected Behavior
No diff when running
tofu planwith aGITHUB_TOKENthat cannot read (squash or rebase) merge settings,1 similar to howvulnerability_alertswas fixed in #3144.Actual Behavior
tofu planreports changes formerge_commit_message,merge_commit_title,squash_merge_commit_message, andsquash_merge_commit_titleon every run.Perhaps the provider cannot read these fields with an unprivileged token, so it gets
null. It then compares those unknown values against the config and plans to set them to provider default (PR_TITLE,MERGE_MESSAGE, etc.).Terraform Version
OpenTofu
integrations/github v6.11.1
Affected Resource(s)
github_repositoryTerraform Configuration Files
The full code: https://github.com/lens0021/amber-script-action/blob/dca2d0e3ee1d4cebcf50287e43c8894a72d9f10a/.github/tf/repository.tf
Steps to Reproduce
GITHUB_TOKENwith onlyContents: read, Metadata: read.tofu plan.The full code: https://github.com/lens0021/amber-script-action/blob/dca2d0e3ee1d4cebcf50287e43c8894a72d9f10a/.github/workflows/tf.yaml#L22-L39
Debug Output
Panic Output
Code of Conduct
Footnotes
The reason I tried this was I wanted a GitHub Actions run without PAT. ↩