Skip to content

[BUG]: github_repository doesn't read merge settings for archived repositories, causing a permanent diff #3758

Backlog

Description

@gaima8

Expected Behavior

An archived github_repository whose config matches its real settings plans with no changes.

Actual Behavior

Every plan shows an in-place update adding allow_auto_merge, allow_merge_commit, allow_rebase_merge, allow_squash_merge, allow_update_branch, delete_branch_on_merge, merge_commit_message, merge_commit_title, squash_merge_commit_message, squash_merge_commit_title and web_commit_signoff_required. Apply skips updates to archived repositories, so the diff never settles.

The cause is in resourceGithubRepositoryRead, which only sets these fields when the repository isn't archived:

// TODO: Validate this behavior as I can see these fields being returned even when archived
// GitHub API doesn't respond following parameters when repository is archived
if !d.Get("archived").(bool) {

The REST API does return them for archived repositories: GET /repos/{owner}/{repo} includes allow_merge_commit, merge_commit_title and the rest. Removing the condition fixes the diff and still detects real drift: with it removed, changing allow_merge_commit in config shows true -> false.

Terraform Version

OpenTofu v1.12.1, provider v6.12.1. The same code is on main.

GitHub Installation Type

GitHub Enterprise Cloud with Personal Accounts (github.com)

Affected Resource(s)

  • github_repository

Terraform Configuration Files

import {
  to = github_repository.example
  id = "an-archived-repo"
}

resource "github_repository" "example" {
  name                        = "an-archived-repo"
  visibility                  = "private"
  archived                    = true
  allow_merge_commit          = true
  allow_squash_merge          = true
  allow_rebase_merge          = true
  allow_auto_merge            = false
  allow_update_branch         = false
  delete_branch_on_merge      = true
  merge_commit_title          = "MERGE_MESSAGE"
  merge_commit_message        = "PR_TITLE"
  squash_merge_commit_title   = "COMMIT_OR_PR_TITLE"
  squash_merge_commit_message = "COMMIT_MESSAGES"
  web_commit_signoff_required = false
}

Steps to Reproduce

  1. Use an archived repository whose settings match the config above.
  2. Run tofu plan: 1 to import, 1 to change, adding the fields listed above.
  3. Build the provider with the if !archived condition removed (patch on gaima8/terraform-provider-github fix/archived-merge-settings) and plan again: 1 to import, 0 to change.

Activity

  1. github-actions commented on Nov 26, 2026

    @github-actions

    👋 Hi, and thank you for opening this issue!

    This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

    You can help us prioritize by adding details, reproduction steps, or a 👍 to issues that matter to you, and by joining the discussion on open issues.


    🤖 This is an automated message.

  2. gaima8 commented on Nov 27, 2026

    @gaima8
    Author

    I have a fix for this on my fork, ready to open as a PR if you'd like one: gaima8@fc34bcc

    It removes the if !archived condition in resourceGithubRepositoryRead, so the merge settings are always read, and adds an acceptance test (reads_merge_settings_of_archived_repositories) that archives a repository with non-default merge settings and then imports it with ImportStateVerify.

    Tested against a GitHub Enterprise Cloud org: archived repositories plan with no changes, and a real difference in config (e.g. allow_merge_commit) still shows as drift.

  3. gaima8 commented on Nov 27, 2026

    @gaima8
    Author

    Correction to the issue: the diff isn't permanent. Applying once stores the configured values (the update itself is skipped, as the repository is archived), and later plans are clean.

    The underlying problem remains: the provider never reads these settings for archived repositories, so state reflects config rather than GitHub, and the first plan after importing an archived repository always shows them being added. The fix above reads the real values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions