Skip to content

[BUG]: Provider produced inconsistent result after apply (v6.9.1) #3049

Description

@Tidschimon

Expected Behavior

When creating github_actions_environment_variable and github_environment_secret I expect terraform to track the state and create the resources successfully.

note:
since I could not find a better place in the form to put this: I assume this bug is highly related to #2843

Actual Behavior

The resources are created but after applying the plan terraform outputs:

provider "module.old_main.provider["registry.terraform.io/integrations/github"]" produced
│ an unexpected new value: Root object was present, but now absent.

Terraform Version

Terraform v1.14.3
on linux_amd64
...

  • provider registry.terraform.io/integrations/github v6.9.1

Affected Resource(s)

  • github_actions_environment_secret
  • github_actions_environment_variable

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "6.9.1"
    }
  }
}

provider "github" {}




resource "github_repository_environment" "environment" {
  repository = "my-repo"
  environment = "default"
}

resource "github_actions_environment_secret" "deployment_key" {
  repository      = "my-repo"
  environment     = github_repository_environment.environment.environment
  secret_name     = "DEPLOYMENT_PRIVATE_KEY"
  plaintext_value = "my-super-secret-key"
}

Steps to Reproduce

run terraform apply to create the resources.

Debug Output

....
  # module.old_main.github_actions_environment_secret.deployment_key will be created
  + resource "github_actions_environment_secret" "deployment_key" {
      + created_at      = (known after apply)
      + environment     = "default"
      + id              = (known after apply)
      + plaintext_value = (sensitive value)
      + repository      = "my-repo"
      + secret_name     = "DEPLOYMENT_PRIVATE_KEY"
      + updated_at      = (known after apply)
    }

...
 

Panic Output

...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.old_main.github_actions_environment_secret.deployment_key, provider "module.old_main.provider[\"registry.terraform.io/integrations/github\"]" produced an
│ unexpected new value: Root object was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Code of Conduct

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

Activity

  1. added
    Type: Bug
    Status: Triage
    on Jan 7, 2026
  2. github-actions commented on Jan 7, 2026

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  3. stevehipwell commented on Jan 7, 2026

    @stevehipwell
    Collaborator

    @Tidschimon please could you fill out the issue template so someone can look into this for you?

  4. changed the title [-][BUG]: Provider produced inconsistent result after apply (v9.1.0)[/-] [+][BUG]: Provider produced inconsistent result after apply (v6.9.1)[/+] on Jan 7, 2026
  5. Tidschimon commented on Jan 9, 2026

    @Tidschimon
    Author

    @stevehipwell I edited the description. I also had to boil down the outputs since this is part of a larger project and I can't share specifics, so I hope the code snippet still makes some sense

  6. stevehipwell commented on Jan 9, 2026

    @stevehipwell
    Collaborator

    @Tidschimon it looks like you're using modules? If so do you have the following block in your sub-module?

    terraform {
      required_providers {
        github = {
          source  = "integrations/github"
        }
      }
    }
  7. Tidschimon commented on Jan 9, 2026

    @Tidschimon
    Author

    @stevehipwell
    Yes to both, I do use modules and I do have that block in the sub-module. The snippet shared in the issue description not only specifies "integrations/github" (I remember earlier versions of this provider had a different name), but it also provides the current version "6.9.1". Or do you mean something different, here?

    Also, I think I would need this block even if I only had one main module, wouldn't I?

    I also think, that this issue is highly related to #2843 but in this case for environment variables and secrets.

  8. stevehipwell commented on Jan 9, 2026

    @stevehipwell
    Collaborator

    @Tidschimon you should have the block with a version in the root module and then the block without a version in sub-modules.

    I also think, that this issue is highly related to #2843 but in this case for environment variables and secrets.

    I think you may be right.

    Are you using github.com or GHEC or GHES?

  9. self-assigned this
    on Jan 9, 2026
  10. removed
    Status: Triage
    on Jan 9, 2026
  11. added this to the v6.10.0 Release milestone on Jan 9, 2026
  12. Tidschimon commented on Jan 9, 2026

    @Tidschimon
    Author

    @stevehipwell
    The repository in question is hosted on github.com but behind a coporate organization, so it practically is a private repository. I know, for this I have to specify the organization as the owner of the repository.
    So the provider block actually looks something like this

    provider "github" {
      owner = "my-organistation"
    }

    I also can confirm that the variables and secrets are in fact created. It is only terraform and the state that have a hiccup there

  13. stevehipwell commented on Jan 9, 2026

    @stevehipwell
    Collaborator

    @Tidschimon so EMU then? Are you using data residency (non-standard URL)?

  14. Tidschimon commented on Jan 9, 2026

    @Tidschimon
    Author

    @stevehipwell I am not 100% sure of the mechanisms at play. From my perspective we are using organizations .
    As far as the relevant part, the repository urls are concerned, these look pretty standard to me.
    They follow the scheme: https://github.com/<organisation>/<repository> if that is what you were looking for.
    so, coming back to the dummy data I so far referenced, this would be:
    https://github.com/my-organisation/my-repo

  15. deiga commented on Jan 9, 2026

    @deiga
    Collaborator

    @Tidschimon just to double-check it's just an Organization on github.com and not an Organization inside an Enterprise on github.com?

    Would you be able to run terraform apply with TF_LOG=DEBUG and post that (redacted of course)?

  16. nickfloyd commented on Jan 9, 2026

    @nickfloyd
    Contributor

    Could this be a race condition in the env secret logic. I remember feeling unsteady about this change because of conditions that could cause 404s.

    GetEnvSecret and GetEnvVariable already perform this check for the given resource.

    When Repositories.Get() 404s (while fetching the metadata for the repository) the precheck might be causing the race condition because it's not checking to see if the actual resource (env secret or env var) were dealing with exists.

    Check me on this but it seems like...

    1. Create or Update creates the secret (for instance)
    2. Then it calls read to hydrate the state
    3. Read calls Repo.Get and could 404 (this is the hand-wavey part that I'm not 100% on)
    4. The resource Id gets set to ""
    5. Now the provider is confused - I just created it but now it's gone.

    I feel like we need to remove the status code check and id set part of this:

    repo, _, err := client.Repositories.Get(ctx, owner, repoName)
    	if err != nil {
    		var ghErr *github.ErrorResponse
    		if errors.As(err, &ghErr) {
    			if ghErr.Response.StatusCode == http.StatusNotFound {
    				log.Printf("[INFO] Removing environment secret %s from state because it no longer exists in GitHub",
    					d.Id())
    				d.SetId("")
    				return nil
    			}
    		}
    		return err
    	}
    
  17. Tidschimon commented on Jan 12, 2026

    @Tidschimon
    Author

    Sorry for the late reply. Over the weekend I set up a minimal example with one of my personal repositories which was working flawlessly. I could create the environment and a secret and the state was also tracked.
    Since the Github resources are only a small part of all that is to be deployed, I just extracted them to a minimal example, so I also could redact the debug output a bit better.
    I am applying this terraform script:

    terraform {
      required_providers {
        github = {
          source = "integrations/github"
          version = "6.9.1"
        }
      }
    }
    
    provider "github" {
      owner = "<organization>"
    }
    
    
    data "github_repository" "repo" {
      name = "<repository>"
    }
    
    resource "github_repository_environment" "environment" {
      repository = data.github_repository.repo.name
    
      environment = "terraform:mvp"
    }
    
    resource "github_actions_environment_secret" "my_secret" {
      repository      = data.github_repository.repo.name
      environment     = github_repository_environment.environment.environment
      secret_name     = "MY_SECRET"
      plaintext_value = "supersecret"
    }

    When applied this produces the following debug log.

    debug.log

    As side note: The environment and the secret are successfully created, only the feedback doesn't seem to make it back.
    I hope this helps

    EDIT:
    The environment itself seems to make it into the state, though, so it is only the secret/variable that has problems

  18. stevehipwell commented on Jan 12, 2026

    @stevehipwell
    Collaborator

    OK, I think there are two actual defects here. The first, less common issue (at least on github.com) is related to a lack of support for the scenario where the secret hasn't been fully replicated within the system when we look it up to get the dates. The second, and likely the issue in your reproduction, is due to there being no escaping for the resource ID which uses a : to seperate the individual parts of the ID.

    @Tidschimon could you attempt to reproduce after swapping out the : in your environment name?

  19. Tidschimon commented on Jan 12, 2026

    @Tidschimon
    Author

    @stevehipwell that, my friend, is a bullseye!
    Switching out the : for e.g. an _ yields no problems.

    The last question would then be, how to continue from here?
    Is escaping the : something you guys will tackle or something I just should not do?

  20. stevehipwell commented on Jan 12, 2026

    @stevehipwell
    Collaborator

    @Tidschimon I should be able to fix this as part of #3069 but I don't have a timeline for this.

  21. Tidschimon commented on Jan 13, 2026

    @Tidschimon
    Author

    At this point: Thanks a lot for the exchange, the troubleshooting and the support in getting this sorted out.
    ❤️

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

Metadata

Metadata

Assignees

Labels

Type: Bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions