Skip to content

[BUG]: Error: unexpected status code: 404 Not Found when utilizing a local module #2066

Closed as not planned

Description

@otola

Expected Behavior

The github_repository_file should have been created within the provided organisation repository. Interesrtingly in the debug logs I can see that the organisation name isn't being sent through in the request. The owner field seems to be ignored. When creating a direct github_repository_file resource without utilising a module this works without an issue.

Actual Behavior

Error received. Error: unexpected status code: 404 Not Found

Terraform Version

1.6.6

Affected Resource(s)

  • github_repository_file

Terraform Configuration Files

### Provider Config ###

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

provider "github" {
  owner = "orgName"
}

### Module ###

resource "github_repository_file" "main-template" {
  repository          = var.repository
  branch              = var.branch
  file                = var.file
  content             = var.content
  commit_message      = var.commit_message
  commit_author       = var.commit_author
  commit_email        = var.commit_email
  overwrite_on_create = var.overwrite_on_create
}


module "file-to-create" {
  source = "../../../modules/github/github-file-creation"
  repository = "repoName"
  branch = main
  file = "filetocreate.txt"
  content = "test"
}

Steps to Reproduce

terraform plan

Debug Output

2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: ---[ REQUEST ]---------------------------------------
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: GET /repos/otola/repoName/branches/develop HTTP/1.1
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: Host: api.github.com
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: User-Agent: go-github/v55.0.0
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: Accept: application/vnd.github.v3+json,application/vnd.github.stone-crop-preview+json
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: X-Github-Api-Version: 2022-11-28
2023-12-19T17:23:37.612Z [DEBUG] provider.terraform-provider-github_v5.42.0: Accept-Encoding: gzip

Panic Output

No response

Code of Conduct

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

Activity

  1. added
    Status: Triage
    Type: Bug
    on Dec 19, 2023
  2. added
    Status: Up for grabs
    and removed
    Status: Triage
    on Jan 4, 2024
  3. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Jan 4, 2024
  4. kfcampbell commented on Jan 5, 2024

    @kfcampbell
    Contributor

    If you're using separate modules and the org name isn't being sent, you need to follow the directions in our docs here:

    You must add a required_providers block to every module that will create resources with this provider. If you do not explicitly require integrations/github in a submodule, your terraform run may break in hard-to-troubleshoot ways.

  5. github-actions commented on Oct 2, 2024

    @github-actions

    👋 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!

  6. added
    Status: Stale
    on Oct 2, 2024
  7. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleStatus: Up for grabsType: Bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions