Skip to content

Upgrading provider version causes a terraform plan on merge commit message/title #1295

Closed as not planned

Description

@garrettheel

Opening an issue on behalf of @danielpops and @chaosaffe from discussion in #1263. This would have began as of v4.31.0.

This PR causes a plan like so to be generated on repositories:

  # github_repository.repo["the_repo"] will be updated in-place
  ~ resource "github_repository" "repo" {
        id                          = "the_repo"
      + merge_commit_message        = "PR_TITLE"
      + merge_commit_title          = "MERGE_MESSAGE"
        name                        = "the_repo"
      + squash_merge_commit_message = "COMMIT_MESSAGES"
      + squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
        # (28 unchanged attributes hidden)
}

Presumably this plan may confuse users since it says something is going to happen, however the changes are simply setting new defaults and they are safe to apply.

Activity

  1. garrettheel commented on Sep 20, 2022

    @garrettheel
    ContributorAuthor

    @danielpops I think you're saying that the impact is that a plan is shown even though there is no effective change (the "new values" are simply the defaults, they just didn't exist in the tf state previously).

    I don't know of a way to avoid terraform showing a plan difference here. Setting no default values would still display a plan like:

      ~ repository = {
          - branches                                = [] -> null
            id                                      = "repo"
          + merge_commit_message                    = null
          + merge_commit_title                      = null
            name                                    = "repo"
          + squash_merge_commit_message             = null
          + squash_merge_commit_title               = null
            # (34 unchanged elements hidden)
        }
    

    This seems like one of those unavoidable issues given how terraform currently tracks state, and I can't find a way to avoid it and still add properties to the repository object over time. If someone know of a better solution then I'm happy to take a look and implement it.

  2. scruplelesswizard commented on Oct 12, 2022

    @scruplelesswizard

    If preferred I can open a separate issue, as this doesn't fully encompass the issues we are experiencing.

    The challenge on my side is that our org doesn't allow for merge or squash commits. The GH API doesn't allow setting defaults for merge and squash titles and messages while those merge types are disabled, putting us in a state where we are unable to upgrade the Github provider.

    While the addition in the plan is inconvenient, adding a requirement for merge and squash defaults breaks the provider for anyone with merge or squash disabled on a repo.

  3. garrettheel commented on Oct 12, 2022

    @garrettheel
    ContributorAuthor

    @chaosaffe I can't repro your issue. Here's what I tried:

    1. Create a repo with an older version of the provider (4.30.0) with allow_merge_commit = false and allow_squash_merge = false
    2. Bump the provider version to latest (~> 5)
    3. Apply a plan that looks like below:
      ~ resource "github_repository" "private" {
            id                          = "test-repo"
          + merge_commit_message        = "PR_TITLE"
          + merge_commit_title          = "MERGE_MESSAGE"
            name                        = "test-repo"
          + squash_merge_commit_message = "COMMIT_MESSAGES"
          + squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
            # (25 unchanged attributes hidden)
    

    For me, the above applies successfully. Is there something I'm missing as far as reproducing?

  4. foosinn commented on Oct 14, 2022

    @foosinn

    hey @garrettheel,

    i find it odd that updating changes the repositories.

    Do the displayed changes cause changes on the github repos?

  5. rsrchboy commented on Feb 13, 2023

    @rsrchboy

    FWIW, I'm also seeing the behaviour described. This is reminding me of the schema/state upgrade functionality the SDK provides -- I don't have time to dig into it now, but it seems like if the state is changing to have a new default, then an upgrader might be in order.

    https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema#StateUpgrader

  6. added
    Type: Bug
    Status: Up for grabs
    on Feb 17, 2023
  7. moved this to 🔥 Backlog in 🧰 Octokit Activeon Feb 17, 2023
  8. scruplelesswizard commented on Mar 22, 2023

    @scruplelesswizard

    My apologies, I haven't had sufficient cycles to get back to this issue previously.

    Unfortunately we encountered this bug merging a time-sensitive PR and had to pin to a previous version to avoid this issue. I'll make note to bump the provider and confirm the issue still exists.

  9. chemmi commented on Mar 30, 2023

    @chemmi

    As a workaround I ignored changes in the corresponding fields.

      lifecycle {
        ignore_changes = [
          merge_commit_message,
          merge_commit_title,
          squash_merge_commit_message,
          squash_merge_commit_title,
        ]
      }

    For me this is fine, since I do not want to configure PR merge strategies or commit defaults with terraform at all. This fixed my plan, but I do not know what changes in state the provider does under the hood.

    Perhaps this also fixes the case where merge or squash are explicitly disabled.

    @chaosaffe

  10. scruplelesswizard commented on Apr 21, 2023

    @scruplelesswizard

    @chemmi thanks for that workaround!

  11. added
    hacktoberfest
    on Sep 20, 2023
  12. github-actions commented on Jun 19, 2024

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  13. added
    Status: Stale
    on Jun 19, 2024
  14. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleStatus: Up for grabsType: Bughacktoberfest

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions