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

[BUG]: repo_id attribute not generated #1940

Open
1 task done
neilharris123 opened this issue Oct 6, 2023 · 3 comments
Open
1 task done

[BUG]: repo_id attribute not generated #1940

neilharris123 opened this issue Oct 6, 2023 · 3 comments
Labels
Type: Bug Something isn't working as documented Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@neilharris123
Copy link

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

  • I agree to follow this project's Code of Conduct
@neilharris123 neilharris123 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Oct 6, 2023
@nickfloyd
Copy link
Contributor

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 nickfloyd added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Status: Triage This is being looked at and prioritized labels Oct 6, 2023
@deepbrook
Copy link

deepbrook commented Nov 20, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
None yet
Development

No branches or pull requests

3 participants