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

data source github_repository_file assumes the repository isn't in an org and assumes the repository was created by the github token owner.

Open conner-foreflight opened this issue 3 years ago • 8 comments

The github_repository_file data source was added in the last release. It returns 404 no matter what I try. It looks like instead of using the provided repository name, it prepends the username of the github token. So, it is assuming that the repo is owed by the user and that the repo is also not an organization repo Below is an example trying to pull a file from this repository.

Terraform Configuration Files

data "github_repository_file" "lambda_file" {
  repository          = "integrations/terraform-provider-github"
  branch              = "main"
  file                = "README.md"
}

provider "github" {
  token = "ghp_sometokenmemberofanorg"
}

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

I've tried it with variations such as:

data "github_repository_file" "lambda_file" {
  repository          = "integrations/terraform-provider-github"
  branch              = "main"
  file                = "README.md"
}

and

data "github_repository_file" "lambda_file" {
  repository          = "terraform-provider-github"
  branch              = "main"
  file                = "README.md"
}

Debug Output

bash-3.2$ terraform plan ╷ │ Error: unexpected status code: 404 Not Found │ │ with data.github_repository_file.lambda_file, │ on test.tf line 1, in data "github_repository_file" "lambda_file": │ 1: data "github_repository_file" "lambda_file" { │ ╵ bash-3.2$ export TF_LOG="DEBUG" bash-3.2$ terraform plan 2021-10-14T16:39:40.259-0500 [DEBUG] Adding temp file log sink: /var/folders/nz/7pk419rj4dzf8mm5pr5290040000gp/T/terraform-log662639515 2021-10-14T16:39:40.260-0500 [INFO] Terraform version: 0.15.4 2021-10-14T16:39:40.260-0500 [INFO] Go runtime version: go1.16.3 2021-10-14T16:39:40.260-0500 [INFO] CLI args: []string{"/usr/local/bin/terraform", "plan"} 2021-10-14T16:39:40.260-0500 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc 2021-10-14T16:39:40.260-0500 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2021-10-14T16:39:40.260-0500 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2021-10-14T16:39:40.260-0500 [DEBUG] ignoring non-existing provider search directory /Users/conner/.terraform.d/plugins 2021-10-14T16:39:40.260-0500 [DEBUG] ignoring non-existing provider search directory /Users/conner/Library/Application Support/io.terraform/plugins 2021-10-14T16:39:40.260-0500 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins 2021-10-14T16:39:40.260-0500 [INFO] CLI command args: []string{"plan"} 2021-10-14T16:39:40.262-0500 [DEBUG] New state was assigned lineage "e9e172a4-e825-8f6a-51bc-5ccb6b1f82f1" 2021-10-14T16:39:40.320-0500 [DEBUG] checking for provisioner in "." 2021-10-14T16:39:40.322-0500 [DEBUG] checking for provisioner in "/usr/local/bin" 2021-10-14T16:39:40.322-0500 [INFO] Failed to read plugin lock file .terraform/plugins/darwin_amd64/lock.json: open .terraform/plugins/darwin_amd64/lock.json: no such file or directory 2021-10-14T16:39:40.323-0500 [INFO] backend/local: starting Plan operation 2021-10-14T16:39:40.324-0500 [DEBUG] created provider logger: level=debug 2021-10-14T16:39:40.324-0500 [INFO] provider: configuring client automatic mTLS 2021-10-14T16:39:40.357-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 args=[.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0] 2021-10-14T16:39:40.361-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79062 2021-10-14T16:39:40.361-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 2021-10-14T16:39:40.374-0500 [INFO] provider.terraform-provider-github_v4.16.0: configuring server automatic mTLS: timestamp=2021-10-14T16:39:40.374-0500 2021-10-14T16:39:40.408-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: plugin address: address=/var/folders/nz/7pk419rj4dzf8mm5pr5290040000gp/T/plugin769247669 network=unix timestamp=2021-10-14T16:39:40.408-0500 2021-10-14T16:39:40.409-0500 [DEBUG] provider: using plugin: version=5 2021-10-14T16:39:40.453-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unimplemented desc = unknown service plugin.GRPCStdio" 2021-10-14T16:39:40.454-0500 [DEBUG] No provider meta schema returned 2021-10-14T16:39:40.458-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79062 2021-10-14T16:39:40.458-0500 [DEBUG] provider: plugin exited 2021-10-14T16:39:40.458-0500 [INFO] terraform: building graph: GraphTypeValidate 2021-10-14T16:39:40.459-0500 [DEBUG] ProviderTransformer: "data.github_repository_file.lambda_file" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/integrations/github"] 2021-10-14T16:39:40.459-0500 [DEBUG] ReferenceTransformer: "data.github_repository_file.lambda_file" references: [] 2021-10-14T16:39:40.459-0500 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/integrations/github"]" references: [] 2021-10-14T16:39:40.460-0500 [DEBUG] Starting graph walk: walkValidate 2021-10-14T16:39:40.460-0500 [DEBUG] created provider logger: level=debug 2021-10-14T16:39:40.460-0500 [INFO] provider: configuring client automatic mTLS 2021-10-14T16:39:40.492-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 args=[.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0] 2021-10-14T16:39:40.496-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79063 2021-10-14T16:39:40.496-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 2021-10-14T16:39:40.509-0500 [INFO] provider.terraform-provider-github_v4.16.0: configuring server automatic mTLS: timestamp=2021-10-14T16:39:40.509-0500 2021-10-14T16:39:40.544-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: plugin address: address=/var/folders/nz/7pk419rj4dzf8mm5pr5290040000gp/T/plugin206281242 network=unix timestamp=2021-10-14T16:39:40.543-0500 2021-10-14T16:39:40.544-0500 [DEBUG] provider: using plugin: version=5 2021-10-14T16:39:40.586-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unimplemented desc = unknown service plugin.GRPCStdio" 2021-10-14T16:39:40.588-0500 [DEBUG] No provider meta schema returned 2021-10-14T16:39:40.594-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79063 2021-10-14T16:39:40.594-0500 [DEBUG] provider: plugin exited 2021-10-14T16:39:40.594-0500 [INFO] backend/local: plan calling Plan 2021-10-14T16:39:40.594-0500 [INFO] terraform: building graph: GraphTypePlan 2021-10-14T16:39:40.594-0500 [DEBUG] ProviderTransformer: "data.github_repository_file.lambda_file (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/integrations/github"] 2021-10-14T16:39:40.595-0500 [DEBUG] ReferenceTransformer: "data.github_repository_file.lambda_file (expand)" references: [] 2021-10-14T16:39:40.595-0500 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/integrations/github"]" references: [] 2021-10-14T16:39:40.595-0500 [DEBUG] Starting graph walk: walkPlan 2021-10-14T16:39:40.595-0500 [DEBUG] created provider logger: level=debug 2021-10-14T16:39:40.596-0500 [INFO] provider: configuring client automatic mTLS 2021-10-14T16:39:40.626-0500 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 args=[.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0] 2021-10-14T16:39:40.630-0500 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79064 2021-10-14T16:39:40.630-0500 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 2021-10-14T16:39:40.644-0500 [INFO] provider.terraform-provider-github_v4.16.0: configuring server automatic mTLS: timestamp=2021-10-14T16:39:40.644-0500 2021-10-14T16:39:40.678-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: plugin address: address=/var/folders/nz/7pk419rj4dzf8mm5pr5290040000gp/T/plugin924949319 network=unix timestamp=2021-10-14T16:39:40.677-0500 2021-10-14T16:39:40.678-0500 [DEBUG] provider: using plugin: version=5 2021-10-14T16:39:40.721-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unimplemented desc = unknown service plugin.GRPCStdio" 2021-10-14T16:39:40.723-0500 [DEBUG] No provider meta schema returned 2021-10-14T16:39:40.726-0500 [WARN] ValidateProviderConfig from "provider["registry.terraform.io/integrations/github"]" changed the config value, but that value is unused 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:40 [DEBUG] Selecting owner from GITHUB_OWNER environment variable 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:40 [DEBUG] Setting write_delay_ms to 1000 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:40 [DEBUG] Github API Request Details: 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ---[ REQUEST ]--------------------------------------- 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: GET /user HTTP/1.1 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Host: api.github.com 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: User-Agent: go-github 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Accept: application/vnd.github.v3+json 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Accept-Encoding: gzip 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ----------------------------------------------------- 2021-10-14T16:39:40.726-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:40 [TRACE] Acquiring lock for GitHub API request (%!q()) 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [TRACE] Releasing lock for GitHub API request (%!q()) 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [DEBUG] Github API Response Details: 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ---[ RESPONSE ]-------------------------------------- 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: HTTP/2.0 200 OK 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Access-Control-Allow-Origin: * 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Cache-Control: private, max-age=60, s-maxage=60 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Content-Security-Policy: default-src 'none' 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Content-Type: application/json; charset=utf-8 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Date: Thu, 14 Oct 2021 21:39:41 GMT 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Etag: W/"3200ac6de840a8bf31dfc3fa4fae35c4e3bd4e8d253a1e2eb0247f2cdeb979db" 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Github-Authentication-Token-Expiration: 2021-11-13 20:20:17 UTC 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Last-Modified: Tue, 10 Aug 2021 15:34:03 GMT 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Server: GitHub.com 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Vary: Accept, Authorization, Cookie, X-GitHub-OTP 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Vary: Accept-Encoding, Accept, X-Requested-With 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Accepted-Oauth-Scopes: 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Content-Type-Options: nosniff 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Frame-Options: deny 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Github-Media-Type: github.v3; format=json 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Github-Request-Id: DF88:20BA:BC7CBA:174B462:6168A39C 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Oauth-Scopes: repo 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Limit: 5000 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Remaining: 4995 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Reset: 1634250098 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Resource: core 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Used: 5 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Xss-Protection: 0 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: { 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "login": "conner-foreflight", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "id": 81982138, 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "node_id": "MDQ6VXNlcjgxOTgyMTM4", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "avatar_url": "https://avatars.githubusercontent.com/u/81982138?v=4", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "gravatar_id": "", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "url": "https://api.github.com/users/conner-foreflight", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "html_url": "https://github.com/conner-foreflight", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "followers_url": "https://api.github.com/users/conner-foreflight/followers", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "following_url": "https://api.github.com/users/conner-foreflight/following{/other_user}", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "gists_url": "https://api.github.com/users/conner-foreflight/gists{/gist_id}", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "starred_url": "https://api.github.com/users/conner-foreflight/starred{/owner}{/repo}", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "subscriptions_url": "https://api.github.com/users/conner-foreflight/subscriptions", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "organizations_url": "https://api.github.com/users/conner-foreflight/orgs", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "repos_url": "https://api.github.com/users/conner-foreflight/repos", 2021-10-14T16:39:41.130-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "events_url": "https://api.github.com/users/conner-foreflight/events{/privacy}", 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "received_events_url": "https://api.github.com/users/conner-foreflight/received_events", 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "type": "User", 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "site_admin": false, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "name": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "company": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "blog": "", 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "location": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "email": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "hireable": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "bio": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "twitter_username": null, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "public_repos": 0, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "public_gists": 0, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "followers": 0, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "following": 0, 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "created_at": "2021-04-05T16:43:55Z", 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "updated_at": "2021-08-10T15:34:03Z" 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: } 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ----------------------------------------------------- 2021-10-14T16:39:41.131-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [DEBUG] Token present; configuring authenticated owner: conner-foreflight 2021-10-14T16:39:41.132-0500 [DEBUG] Resource instance state not found for node "data.github_repository_file.lambda_file", instance data.github_repository_file.lambda_file 2021-10-14T16:39:41.132-0500 [DEBUG] ReferenceTransformer: "data.github_repository_file.lambda_file" references: [] 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [DEBUG] Github API Request Details: 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ---[ REQUEST ]--------------------------------------- 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: GET /repos/conner-foreflight/integrations/terraform-provider-github/branches/main HTTP/1.1 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Host: api.github.com 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: User-Agent: go-github 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Accept: application/vnd.github.v3+json 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Accept-Encoding: gzip 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ----------------------------------------------------- 2021-10-14T16:39:41.133-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [TRACE] Acquiring lock for GitHub API request ("integrations/terraform-provider-github:main") 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [TRACE] Releasing lock for GitHub API request ("integrations/terraform-provider-github:main") 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021/10/14 16:39:41 [DEBUG] Github API Response Details: 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ---[ RESPONSE ]-------------------------------------- 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: HTTP/2.0 404 Not Found 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Access-Control-Allow-Origin: * 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Content-Security-Policy: default-src 'none' 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Content-Type: application/json; charset=utf-8 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Date: Thu, 14 Oct 2021 21:39:41 GMT 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Github-Authentication-Token-Expiration: 2021-11-13 20:20:17 UTC 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin 2021-10-14T16:39:41.260-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Server: GitHub.com 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: Vary: Accept-Encoding, Accept, X-Requested-With 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Accepted-Oauth-Scopes: repo 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Content-Type-Options: nosniff 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Frame-Options: deny 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Github-Media-Type: github.v3; format=json 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Github-Request-Id: DF88:20BA:BC7CC9:174B482:6168A39D 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Oauth-Scopes: repo 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Limit: 5000 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Remaining: 4994 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Reset: 1634250098 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Resource: core 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Ratelimit-Used: 6 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: X-Xss-Protection: 0 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: { 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "message": "Not Found", 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: "documentation_url": "https://docs.github.com/rest" 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: } 2021-10-14T16:39:41.261-0500 [DEBUG] provider.terraform-provider-github_v4.16.0: ----------------------------------------------------- 2021-10-14T16:39:41.261-0500 [INFO] backend/local: plan operation completed ╷ │ Error: unexpected status code: 404 Not Found │ │ with data.github_repository_file.lambda_file, │ on test.tf line 1, in data "github_repository_file" "lambda_file": │ 1: data "github_repository_file" "lambda_file" { │ ╵ 2021-10-14T16:39:41.266-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/integrations/github/4.16.0/darwin_amd64/terraform-provider-github_v4.16.0 pid=79064 2021-10-14T16:39:41.266-0500 [DEBUG] provider: plugin exited

Expected Behavior

The Data resource populates the file info

Actual Behavior

404 error

Steps to Reproduce

  1. copy the above with your own token, terraform

conner-foreflight avatar Oct 14 '21 21:10 conner-foreflight

Confirmed that this is a bug due to the recently added data source coming from it's resource counterpart.

Adding an owner field here makes a lot of sense from a usability perspective.

jcudit avatar Nov 02 '21 20:11 jcudit

This issue also affects resources. The plan somehow works fine but the apply leads to the not found issue

rotilho avatar Nov 08 '21 15:11 rotilho

Confirmed that this is a bug due to the recently added data source coming from it's resource counterpart. Adding an owner field here makes a lot of sense from a usability perspective.

I have the same problem here. But adding the owner param into provider configuration don't solve the problem.

image

I have this structure:

├── backend.tf
├── locals.tf
├── provider.tf
├── repository
│   ├── data-sources.tf
│   ├── secrets.tf
│   ├── variables.tf
│   └── webhook.tf
├── risco-terraform-modules.tf
└── variables.tf

When I'm calling the local module named repository the resource don't get the owner value then I get 404. Below a log level line:

{"@level":"error","@message":"Error: GET https://api.github.com/repos//risco-terraform-gcp-module-monitoring-by-status-code/actions/secrets/public-key: 404 Not Found []","@module":"terraform.ui","@timestamp":"2021-12-12T08:46:32.761759Z","diagnostic":{"severity":"error","summary":"GET https://api.github.com/repos//risco-terraform-gcp-module-monitoring-by-status-code/actions/secrets/public-key: 404 Not Found []","detail":"","address":"module.module_repositories[\"monitoring-by-status-code\"].github_actions_secret.module_secret_tf_auth_token","range":{"filename":"repository/secrets.tf","start":{"line":1,"column":64,"byte":63},"end":{"line":1,"column":65,"byte":64}},"snippet":{"context":"resource \"github_actions_secret\" \"module_secret_tf_auth_token\"","code":"resource \"github_actions_secret\" \"module_secret_tf_auth_token\" {","start_line":1,"highlight_start_offset":63,"highlight_end_offset":64,"values":[]}},"type":"diagnostic"}

FelipeBarrosCruz avatar Dec 12 '21 09:12 FelipeBarrosCruz

Problem is still there. owner parameter doesn't seem to make any difference, environmental variable GITHUB_ORGANIZATION makes it work.

ross-ivanov-oritain avatar Jan 26 '22 05:01 ross-ivanov-oritain

Just ran up against this today and importing was troublesome, too. Trying to add a CODEOWNERS file to one of the two orgs I manage with my TF configuration:

resource "github_repository_file" "myorg_codeowners" {
  for_each = toset(data.github_repositories.myorg_org_prod.full_names)

  repository          = data.github_repository.myorg_org_prod[each.value].name
  branch              = data.github_repository.myorg_org_prod[each.value].default_branch
  file                = ".github/CODEOWNERS"
  content             = "* @myorg/myorg-devs"
  commit_message      = "Managed by Terraform"
  commit_author       = "Firstname Lastname"
  commit_email        = "[email protected]"
  overwrite_on_create = false
}
data "github_repositories" "myorg_org_prod" {
  query = "org:myorg topic:in-production"
}

data "github_repository" "myorg_org_prod" {
  for_each = toset(data.github_repositories.myorg_org_prod.full_names)
  full_name = each.value
}

I had to do this to import for the one repo that already had a CODEOWNERS:

GITHUB_OWNER=myorg terraform import \
'github_repository_file.myorg_codeowners["myorg/common-scripts"]' \
'common-scripts/.github/CODEOWNERS:master'

and this to plan/apply:

GITHUB_OWNER=myorg terraform apply

This was successful but I'd have to add a separate configuration for CODEOWNERS for the other org I manage and invoke them separately. I'm not sure what would happen if they needed to make changes at the same time because the GITHUB_OWNER envvar can only be set to one thing per invocation!

It feels like the whole github plugin needs some work to better respect the org/repo coordinates of a repository.

colindean avatar Mar 07 '22 19:03 colindean

This is still broken, please fix soon.

cseatjc avatar Jun 02 '22 02:06 cseatjc

This also happens with a github_repository data source.

data "github_repository" "main" {
  full_name = format("%s/%s", var.github_owner, var.repository_name)
}

liviudm avatar Sep 06 '22 05:09 liviudm

I am also getting this when just trying to get a file that I know exists.

data "github_repository" "ftf-account-management" {
  full_name = "FundThatFlip/ftf-account-management"
}

data "github_repository_file" "cognito-css" {
  repository = data.github_repository.ftf-account-management.name
  branch = "dev"
  file = ".gitignore"
}

I am seeing error:

╷
│ Error: unexpected status code: 404 Not Found
│
│   with data.github_repository_file.cognito-css,
│   on cognito.tf line 259, in data "github_repository_file" "cognito-css":
│  259: data "github_repository_file" "cognito-css" {
│
╵

benniemosher avatar Sep 23 '22 12:09 benniemosher

For the repo that needs to have files, auto_init = true and github_repository_file needs to depend on github_repository. This is what I found to be true for new repositories.

tracphil avatar Dec 23 '22 22:12 tracphil

When can we get a release with this fix in?

g-m-o-n-e-y avatar Jan 20 '23 14:01 g-m-o-n-e-y

I'm planning on cutting a new release today!

kfcampbell avatar Jan 20 '23 18:01 kfcampbell

Has there been any fix on this? still facing this issue in an organization owned repository

unoscar avatar Feb 29 '24 16:02 unoscar