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

GitHub module source truncates branch name after slash #34771

Closed
brettcurtis opened this issue Mar 5, 2024 · 9 comments · May be fixed by #35466
Closed

GitHub module source truncates branch name after slash #34771

brettcurtis opened this issue Mar 5, 2024 · 9 comments · May be fixed by #35466

Comments

@brettcurtis
Copy link

brettcurtis commented Mar 5, 2024

Terraform Version

Terraform v1.7.4
on linux_amd64

Terraform Configuration Files

module "kubernetes" {
  source = "github.com/osinfra-io/terraform-google-kubernetes-engine?ref=brettcurtis/issue17"

  istio_gateway_ssl = var.istio_gateway_ssl
  project_id        = module.project.project_id
}

Debug Output

Error: Failed to download module
│ 
│   on main.tf line 96:
│   96: module "kubernetes" {
│ 
│ Could not download module "kubernetes" (main.tf:96) source code from
│ "git::https://github.com/osinfra-io/terraform-google-kubernetes-engine.git?ref=brettcurtis":
│ error downloading
│ 'https://github.com/osinfra-io/terraform-google-kubernetes-engine.git?ref=brettcurtis':
│ /usr/bin/git exited with 1: error: pathspec 'brettcurtis' did not match any
│ file(s) known to git

Expected Behavior

I'd expect the code to initialize.

Actual Behavior

It seems to truncate the name of my branch following the slash.

Steps to Reproduce

  1. terraform init

Additional Context

No response

References

No response

@brettcurtis brettcurtis added bug new new issue not yet triaged labels Mar 5, 2024
@jbardin jbardin added enhancement and removed bug labels Mar 6, 2024
@jbardin
Copy link
Member

jbardin commented Mar 6, 2024

Hi @brettcurtis,

Thanks for filing the issue. The branch specifier in this syntax is part of the URL query parameters, and the / is one of the reserved characters within a URI query component. This means that it must appear encoded as %2F to be parsed correctly.

The following module config initializes successfully:

module "kubernetes" {
  source = "github.com/osinfra-io/terraform-google-kubernetes-engine?ref=brettcurtis%2Fissue17"

  istio_gateway_ssl = var.istio_gateway_ssl
  project_id        = module.project.project_id
}

@jbardin jbardin added documentation and removed new new issue not yet triaged labels Mar 6, 2024
@brettcurtis
Copy link
Author

Ok thanks bud! I could have sworn this worked fine for me in the past so i figured it was a bug.

@ashwin1596
Copy link

Hi,

I am interested in working on this issue, update the documentation and believe it will help me learn more about the codebase.

Could you please confirm if I can start working on it?

Thank you!

@crw
Copy link
Collaborator

crw commented Jul 15, 2024

Hi @ashwin1596, thanks for offering to update the docs. Anyone can suggest changes to the docs, so feel free to do so. If this was going to be documented, I suppose it would be here: https://developer.hashicorp.com/terraform/language/modules/sources#github -- maybe just a note about making sure the URL is valid? It isn't really Terraform-specific guidance, just how to properly format URLs.

I would also suggest reading https://github.com/hashicorp/terraform/blob/main/.github/CONTRIBUTING.md. Thanks!

@brettcurtis
Copy link
Author

Howdy, at the time of this issue I was pointing out that I thought this use to work so it felt buggy. Today in terraform 1.9.2 it works again...

@crw
Copy link
Collaborator

crw commented Jul 17, 2024

That is curious, I wonder what changed. I will raise this in triage to see if we know why the behavior may have changed.

@crw
Copy link
Collaborator

crw commented Aug 5, 2024

Linking this with hashicorp/go-getter#479 per request of @jbardin.

@jbardin
Copy link
Member

jbardin commented Aug 9, 2024

Thanks @crw, looking more closely that is related only to a gitlab issue parsed within go-getter. I'm going to close this with the dupe #34554.

@jbardin jbardin closed this as completed Aug 9, 2024
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants