hashicorp/terraform · error
GitHub URLs should be github.com/username/repo
Error message
GitHub URLs should be github.com/username/repo
What it means
Thrown by detectGitHub when a source starting with 'github.com/' splits into fewer than 3 parts. The detector requires at minimum host/username/repo (parts[0..2]); anything shorter has no repo component and cannot form a valid git HTTP address.
Solutions
- Provide the full repository path: 'github.com/USERNAME/REPO'.
- Copy the URL directly from the GitHub repo page (including the repo name).
- Optionally append ref via query string: 'github.com/USERNAME/REPO?ref=v1.2.3'.
Example fix
# before (no repo) source = "github.com/hashicorp" # after source = "github.com/hashicorp/example"
Defensive patterns
Strategy: validation
Validate before calling
// Validate a GitHub shorthand has at least host/user/repo.
// func validGitHubShorthand(src string) error {
// if !strings.HasPrefix(src, "github.com/") { return nil }
// if len(strings.Split(src, "/")) < 3 {
// return fmt.Errorf("GitHub source must be github.com/USER/REPO")
// }
// return nil
// } Prevention
- Copy repository URLs straight from the GitHub repo page.
- Always include both username and repo segments.
- Lint module sources in CI with a regex like ^github\.com/[^/]+/[^/]+.
When it happens
Trigger: Source is 'github.com/' alone or 'github.com/<username>' with no repo segment; the prefix matches but the path is incomplete.
Common situations: User copies only the org/profile URL instead of a repository URL; trailing slash artifacts; autocomplete/copy mistake.
Related errors
- invalid source address
- URL is not a valid GCS URL
- URL is not a valid S3 URL
- can't use local directory
- detected subdirectory path
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/c15e2362e682d8be.
Report an issue: GitHub.
Appendix: source
Thrown at internal/getmodules/moduleaddrs/detect_git.go:47
return "", false, nil
}
return "git::" + u.String(), true, nil
}
// detectGitHub detects shorthand schemeless references to github.com and
// translates them into git HTTP source addresses.
func detectGitHub(src string) (string, bool, error) {
if len(src) == 0 {
return "", false, nil
}
if strings.HasPrefix(src, "github.com/") {
src, rawQuery, _ := strings.Cut(src, "?")
parts := strings.Split(src, "/")
if len(parts) < 3 {
return "", false, fmt.Errorf(
"GitHub URLs should be github.com/username/repo")
}
urlStr := fmt.Sprintf("https://%s", strings.Join(parts[:3], "/"))
url, err := url.Parse(urlStr)
if err != nil {
return "", true, fmt.Errorf("error parsing GitHub URL: %s", err)
}
url.RawQuery = rawQuery
if !strings.HasSuffix(url.Path, ".git") {
url.Path += ".git"
}
if len(parts) > 3 {
url.Path += "//" + strings.Join(parts[3:], "/")
}
View on GitHub (pinned to d32a084675)