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

vulnerability-alerts 404 #716

Closed
czerasz opened this issue Mar 2, 2021 · 10 comments
Closed

vulnerability-alerts 404 #716

czerasz opened this issue Mar 2, 2021 · 10 comments
Labels
github_enterprise r/repository Status: Stale Used by stalebot to clean house Type: Bug Something isn't working as documented

Comments

@czerasz
Copy link

czerasz commented Mar 2, 2021

Terraform Version

$ terraform -v
Terraform v0.14.5
+ provider registry.terraform.io/integrations/github v4.5.0

Your version of Terraform is out of date! The latest version
is 0.14.7. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

  • github_repository

Terraform Configuration Files

../../modules/tf-repo/main.tf (pseudo code):

resource "github_repository" "this" {
  name        = var.name
  description = var.description

  ...
  vulnerability_alerts = null
}

.terraform.lock.hcl:

# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.

provider "registry.terraform.io/integrations/github" {
  version     = "4.5.0"
  constraints = "4.5.0"
  hashes = [
    "h1:KjMtn8N07rakB/oAwEFlmDd6YhJ5fentdjpF7A0fB3c=",
    "zh:22cb80695782a750ab8dd61357ed92a3ec3260b3cad15b3ed5cbb5371d1190eb",
    "zh:290b3d2b50df075835ff5dba2d02bf834576c9bb20555f715863c68e5ba2b482",
    "zh:31a0f119c5f384771706ddfb89f51c6a66ede1eab0091b19b39de5686c6189d3",
    "zh:393d3f4010c564aa0828082ec64ca014122cbb798fa28a2219d457e37378e300",
    "zh:4e278b74977c7b2eb5805ad549692970fd06546bf92c44d40991d73bc6107221",
    "zh:5762e3b7b23ae10537054513aadcc4ac6abc30a5e38464d15267510564e2ebb4",
    "zh:6fbf45fdb7c8246caccbf2988f7fa0a20a8c8a7bb660a9740d0f5345da5d024f",
    "zh:7f920eac133683763806ecafca2ac8916883368157ad5d1fef4266383ae5170b",
    "zh:c4d812f681f8b842c709deca79b44965a7688da96a1a0437c1d605135d9ea510",
    "zh:c928cb0ef5f2cae8e3e2c4253275ba9708003f768eed878debf7addd38127297",
    "zh:ce4064e833a4d26a7b9d46e438484a9fd1e28f15f3fc7b64b8cd6d39970a875e",
  ]
}

Debug Output

Panic Output

Expected Behavior

If the GHE instance doesn't support vulnerability-alerts end-point and vulnerability_alerts = null or vulnerability_alerts = false then the provider should not panic when 404 is returned by the API.

Actual Behavior

  • repository got created
  • error thrown
    Error: DELETE https://<BASE URL>.io/api/v3/repos/<ORG NAME>/<REPO NAME>/vulnerability-alerts: 404 Not Found []
    
      on ../../modules/tf-repo/main.tf line 1, in resource "github_repository" "this":
      1: resource "github_repository" "this" {
    
  • other resources from the module were not created

Steps to Reproduce

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

  1. terraform apply

Important Factoids

References

@czerasz
Copy link
Author

czerasz commented Mar 2, 2021

Workaround after failed apply:

  • remove github_repository resource from state:

    terraform state rm 'module.this["<REPO NAME>"].github_repository.this'
  • import github_repository resource:

    terraform import 'module.this["<REPO NAME>"].github_repository.this' '<REPO NAME>'
    

@jcudit jcudit added Type: Bug Something isn't working as documented github_enterprise r/repository labels Mar 8, 2021
@alxzndr
Copy link

alxzndr commented Mar 14, 2021

I have the same issue. Thanks for posting a workaround.
edit: workaround is not working for me, i cannot import the repo (it does exist in github..)

@r-bennett
Copy link

This endpoint is actually documented as being available in GHES 2.22, but we ran into the same thing and have confirmed with GitHub support that this is an error in the documentation.

Looks like this is probably means there's a missing test-case from the GHES compatibility tests from #404 as well. It's a slightly weird one in how it crops up as the defaults are different for public and private repos, but I believe running a refresh on a repository resource will always trigger it.

#444 was the change which introduced this, so another workaround is to use 3.0.0 or earlier

@jeffeland
Copy link

The workaround to use the version 3.0.0 from the provider doesn't seem to be available anymore and even the most recent version of the github enterprise doesn't support this feature yet. Any plan for a fix?

@colltoaction
Copy link

Seeing the same behavior. Workaround worked:

$ terraform state rm github_repository.<REPO NAME>
$ terraform import github_repository.<REPO NAME> <REPO NAME>

@joshmyers
Copy link

This is a massive pain and not a great workaround. Any plans for fix?

@tkjef
Copy link

tkjef commented Oct 3, 2021

this was the fix for me, similar to @colltoaction, but with the resource name instead of the repo name in the first 2 spots.

$ terraform state rm github_repository.<RESOURCE_NAME>
$ terraform import github_repository.<RESOURCE_NAME> <REPO NAME>

@github-actions
Copy link

github-actions bot commented Dec 4, 2022

👋 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 Dec 4, 2022
@github-actions github-actions bot removed the Status: Stale Used by stalebot to clean house label Dec 6, 2022
@Danielku15
Copy link
Contributor

this bug is quite a pain, it prevents proper creation of new repositories via terraform. The workarounds are merely a "recovery" measure not something that gets the provider running.

In our case this also leads to subsequent errors. where autolink references are only partially created. Any references created before this error are there, any references created afterwards are reported as:

404 Not Found []

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 May 28, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_enterprise r/repository 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