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: repository data source returns null instead of error when not found #1612

Closed
kbolino opened this issue Mar 22, 2023 · 2 comments
Closed
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@kbolino
Copy link

kbolino commented Mar 22, 2023

Terraform Version

Terraform v1.4.2
on linux_arm64
+ provider registry.terraform.io/integrations/github v5.18.3

Affected Resource(s)

  • Data source github_repository

Terraform Configuration Files

terraform {
  required_version = "~> 1.4"
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 5.18"
    }
  }
}

data "github_repository" "this" {
  name = "nonexistent-repo"
}

output "github_repository_id" {
  value = data.github_repository.this.repo_id
}

Debug Output

https://gist.github.com/kbolino/cf42fd736ff5a2befcde4c2fb751300e

Panic Output

N/A

Expected Behavior

An error, since the repository does not exist.

While this behavior may not be strictly required by Terraform, it is how other providers (e.g. aws) implement singular data sources. There's also nothing in the docs for the data source that would imply it will silently succeed with null results when the repository doesn't exist.

Actual Behavior

The apply succeeds but no output is produced.

Steps to Reproduce

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

  1. TF_LOG=DEBUG terraform apply
  2. TF_LOG=DEBUG terraform output github_repository_id

An example session:

vscode ➜ /workspaces/infrastructure/github-demo (main) $ TF_LOG=DEBUG terraform apply
data.github_repository.this: Reading...
data.github_repository.this: Read complete after 1s

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
vscode ➜ /workspaces/infrastructure/github-demo (main) $ TF_LOG=DEBUG terraform output github_repository_id
╷
│ Warning: No outputs found
│ 
│ The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the `output` keyword and run `terraform refresh` for
│ it to become available. If you are using interpolation, please verify the interpolated value is not empty. You can use the `terraform console` command to assist.
╵

Important Factoids

N/A

References

N/A

@nickfloyd nickfloyd moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Mar 24, 2023
@kfcampbell kfcampbell added Type: Bug Something isn't working as documented Status: Up for grabs Issues that are ready to be worked on by anyone Priority: Normal labels Apr 3, 2023
@JSNortal
Copy link

I think this is intended at least according to this PR #1031

I'm trying to code something against this behaviour. Is this something that will be patched out?

@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
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 Jun 18, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants