Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github_repository_file fails to refresh when branch is deleted #833

Closed
adborden opened this issue Jun 24, 2021 · 2 comments
Closed

github_repository_file fails to refresh when branch is deleted #833

adborden opened this issue Jun 24, 2021 · 2 comments
Labels
r/repository_file Status: Stale Used by stalebot to clean house Type: Bug Something isn't working as documented

Comments

@adborden
Copy link

This issue is most likely to appear if you rename the default branch master -> main, for example. The state refers to the old branch (master) which is now deleted.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

$ terraform -v
Terraform v1.0.1
on darwin_amd64
+ provider registry.terraform.io/hashicorp/github v4.12.0
+ provider registry.terraform.io/integrations/github v4.12.0

Affected Resource(s)

Please list the resources as a list, for example:

  • github_repository_file.issue_templates

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 4.0"
    }
  }
}

provider "github" {
  owner = "adborden"
}

resource "github_repository_file" "issue_templates" {
  repository     = "newrelic-terraform"
  branch         = "main"
  #branch         = "test-deleted"
  file           = "foo.txt"
  content        = "hello world"
  commit_message = "test commit"

  lifecycle {
    ignore_changes = [commit_message]
  }
}

Debug Output

Please provide a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

https://gist.github.com/adborden/ab50ceb300daeedee2575cdd0ab18c0f

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

terraform refresh should complete successfully. terraform plan should show the resource as being in need of an update.

Actual Behavior

What actually happened?

github_repository_file.issue_templates: Refreshing state... [id=newrelic-terraform/foo.txt]
╷
│ Error: Branch test-deleted not found in repository adborden/newrelic-terraform or repository is not readable
│
│   with github_repository_file.issue_templates,
│   on main.tf line 14, in resource "github_repository_file" "issue_templates":
│   14: resource "github_repository_file" "issue_templates" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Set github_repository_file.issue_template's branch to an existing branch (test-deleted).
  2. terraform apply
  3. Delete test-deleted branch in GitHub, change branch to an existing branch e.g. main
  4. terraform refresh

Important Factoids

Is there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@github-actions
Copy link

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Nov 30, 2022
@github-actions github-actions bot removed the Status: Stale Used by stalebot to clean house label Dec 2, 2022
Copy link

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Apr 22, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r/repository_file Status: Stale Used by stalebot to clean house Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants