Skip to content

[BUG]: etag in state changes with every installation token, so import and destroy plans never match under app auth #3694

Closed

Description

@benlangfeld

Expected Behavior

Planning the same change to an unchanged resource twice should produce the same plan, whichever installation token the provider happens to be using.

Actual Behavior

Under GitHub App auth, etag in state changes every time the provider is configured, even though the resource is untouched. GitHub's ETag for an authenticated response depends on the credentials (Vary: Accept, Authorization, Cookie), not only on the resource, and every provider configuration mints a new installation token. As @stevehipwell put it in #3103, the etag "only works with a fixed token".

CustomizeDiff keeps the value out of in-place updates, but import and destroy plans print every attribute, so two plans of the same import never match:

<         etag                                    = "W/\"e9e2bdcb4495fb6a1e2e2ff4b53ab7eb4befca326fc542a2816eff13e80ad231\""
---
>         etag                                    = "W/\"e24c7a9ef275ee40aeff68f99a212e76da368ebe38ec9325fdf47372192820ef\""

That's a github_repository import whose plan was generated in one CI job and regenerated in the apply job. Nothing touched the repository in between, but the apply refused because the plan had changed (we use dflook/terraform-apply, which compares the two plans). Every retry mints another token, so the import can never get through. We saw the same with a github_repository_ruleset being destroyed.

The org-mode acceptance tests hit this too: in run 39583616753, TestAccGithubRepository/imports_repositories_without_error, TestAccGithubRepository/can_update_forked_repository_properties and both TestAccGithubActionsRunnerGroup import tests fail with etag as the only differing attribute. Ten other tests pass ImportStateVerifyIgnore: []string{"etag"} to avoid it.

#3693 adds a reproduction, TestAccGithubRepositoryEtag. Against main at 1b9c5c1:

  • With a single PAT, the etag of an unchanged repository is the same across provider configurations.
  • With a GitHub App, two installation tokens see different ETags for the same repository, and the provider stores a different etag for it at every configuration: W/"1e9526…" != W/"b8c9b1…".

Only the legacy client reads etag back from state (etagTransport sends it as If-None-Match). The new client revalidates through its transport cache instead, so with legacy_client = false the stored value has no consumer and is only noise. One fix that keeps the schema as it is: with the new client, don't populate etag from the response, and leave the legacy client's behaviour alone. Deprecating the attribute for removal could follow separately. Happy to put the fix into #3693 if that direction works for you.

Terraform Version

Terraform v1.17.0, provider v6.13.0 and main at 1b9c5c1

GitHub Installation Type

  • GitHub.com (Free, Pro, or Team)

Affected Resource(s)

Every resource that stores etag from a response, including:

  • github_repository
  • github_repository_ruleset
  • github_actions_runner_group

Terraform Configuration Files

provider "github" {
  owner         = "example-org"
  legacy_client = false

  app_auth {} # GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID, GITHUB_APP_PEM_FILE
}

import {
  to = github_repository.repo
  id = "existing-repo"
}

resource "github_repository" "repo" {
  name = "existing-repo"
}

Steps to Reproduce

  1. Authenticate the provider as a GitHub App.
  2. Run terraform plan -no-color against a configuration that imports an existing repository, and save the output.
  3. Run the same plan again without touching the repository.
  4. Compare the two outputs: only the etag line differs.

Or run TestAccGithubRepositoryEtag from #3693 with app auth.

Debug Output

No response

Activity

  1. github-actions commented on Oct 22, 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 and PRs.


    🤖 This is an automated message.

  2. added a commit that references this issue on Oct 22, 2026
    d2d0ab8
  3. stevehipwell commented on Oct 23, 2026

    @stevehipwell
    Collaborator

    @benlangfeld I agree that this behaviour sucks, but it's been like this forever. I'm expecting to remove it in the next major version along with the legacy client, but to do that we need to get the changes required completed, released and tested.

    Could you elaborate on why you think this needs prioritising and the impact it has?

  4. added
    Type: Bug
    on Oct 23, 2026
  5. benlangfeld commented on Oct 23, 2026

    @benlangfeld
    ContributorAuthor

    This impacts the new client, not only the legacy one. When using https://github.com/dflook/terraform-github-actions, this causes the pipeline to get completely blocked on trivial changes. Precisely for the reason that this has been broken forever, I opened a PR to fix it.

  6. stevehipwell commented on Oct 23, 2026

    @stevehipwell
    Collaborator

    @benlangfeld I've been making this point for a while. I'm happy to review a low cost PR to fix this for the new client only. I just want something I can easily review which has the absolute least added complexity as I wand to get rid of the legacy client and in resource etags ASAP.

    So from your previous PR we only need a storeEtag property on the Owner struct wired up (initially) to when the new client is not being used, and an if meta.storeEtag condition in the resources to check if the etag should be set (no wrapping function); the rest of the code should work correctly. The tests could be updated to remove etag ignores but no changes should be required as they always use the new client.

  7. added a commit that references this issue on Oct 23, 2026
    882d74a
  8. added a commit that references this issue on Nov 19, 2026
    e5065cd
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

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions