Skip to content

[BUG]: False diff for merge_commit_message etc. with unprivileged token #3242

@lens0021

Description

@lens0021

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.

Image

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_repository

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

  1. Use a GITHUB_TOKEN with only Contents: read, Metadata: read.
  2. Run tofu plan.
  3. 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

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

Footnotes

  1. The reason I tried this was I wanted a GitHub Actions run without PAT.

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