terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

[BUG]: repo_id attribute not generated

Open neilharris123 opened this issue 1 year ago • 4 comments

Expected Behavior

The documentations attribute reference suggests an attribute name repo_id should be available.
However, non of our repos attributes contain this key.

Actual Behavior

All other attributes exist, but repo_id does not.

Terraform Version

Terraform 0.13.7 integrations/github version 5.39.0

Affected Resource(s)

  • github_repository

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

No response

Code of Conduct

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

neilharris123 avatar Oct 06 '23 09:10 neilharris123

Hey @neilharris123 Thanks for reaching out. The following is where repo_id is present:

  1. In the resourceGithubRepository schema
  2. In the dataSourceGithubRepository data source
  3. In the github_respoitory docs (as you pointed out)

For clarity, were you expecting to see it somewhere else as well? Have a look at this test that makes use of include_repo_id as part of the query. Docs here. Let me know if that's what you were looking for.

nickfloyd avatar Oct 06 '23 16:10 nickfloyd

Hey @neilharris123 Thanks for reaching out. The following is where repo_id is present:

  1. In the resourceGithubRepository schema
  2. In the dataSourceGithubRepository data source
  3. In the github_respoitory docs (as you pointed out)

For clarity, were you expecting to see it somewhere else as well? Have a look at this test that makes use of include_repo_id as part of the query. Docs here. Let me know if that's what you were looking for.

@nickfloyd ,the issue is with github_repository data source (single repo data source, not multiple repo data source)

That said, I too run into a similar issue. When referencing data.github_repository.<name>.name Terraform complains the related field is not set, implying name returns null:

variable "repositories" {
  type = map(string)
}

data "github_team" "administrators" {
  slug = "code-security"
}

data "github_repository" "owned" {
  for_each = var.repositories
  name     = each.key
}

resource "github_team_repository" "maintainership" {
  for_each = data.github_repository.owned

  team_id    = "@code-security"
  repository = each.value.name
  permission = "push"
}

yields:

│ Error: "repository": required field is not set
│
│   with module.repositories.github_team_repository.maintainership["my-repo"],
│   on modules/repositories/main.tf line 40, in resource "github_team_repository" "maintainership":
│   40: resource "github_team_repository" "maintainership" {
│
╵

As there's no includ_repo_id flag for the single repo data source, I'd say something's off in the read function?

deepbrook avatar Nov 20 '23 14:11 deepbrook

Hey @neilharris123 Thanks for reaching out. The following is where repo_id is present:

  1. In the resourceGithubRepository schema
  2. In the dataSourceGithubRepository data source
  3. In the github_respoitory docs (as you pointed out)

For clarity, were you expecting to see it somewhere else as well? Have a look at this test that makes use of include_repo_id as part of the query. Docs here. Let me know if that's what you were looking for.

@nickfloyd ,the issue is with github_repository data source (single repo data source, not multiple repo data source)

That said, I too run into a similar issue. When referencing data.github_repository.<name>.name Terraform complains the related field is not set, implying name returns null:

variable "repositories" {
  type = map(string)
}

data "github_team" "administrators" {
  slug = "code-security"
}

data "github_repository" "owned" {
  for_each = var.repositories
  name     = each.key
}

resource "github_team_repository" "maintainership" {
  for_each = data.github_repository.owned

  team_id    = "@code-security"
  repository = each.value.name
  permission = "push"
}

yields:

│ Error: "repository": required field is not set
│
│   with module.repositories.github_team_repository.maintainership["my-repo"],
│   on modules/repositories/main.tf line 40, in resource "github_team_repository" "maintainership":
│   40: resource "github_team_repository" "maintainership" {
│
╵

As there's no includ_repo_id flag for the single repo data source, I'd say something's off in the read function?

This issue actually masks the actual bug: loading up repositories not owned by the GITHUB_TOKEN does not raise an error if the repo isn't found. Instead of raising an error, it silently nulls all attributes instead.

deepbrook avatar Jan 24 '24 10:01 deepbrook