{"record":{"id":"a38787470dded6a2","repo":"hashicorp/terraform","slug":"error-parsing-github-url-s","errorCode":null,"errorMessage":"error parsing GitHub URL: %s","messagePattern":"error parsing GitHub URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getmodules/moduleaddrs/detect_git.go","lineNumber":54,"sourceCode":"// translates them into git HTTP source addresses.\nfunc detectGitHub(src string) (string, bool, error) {\n\tif len(src) == 0 {\n\t\treturn \"\", false, nil\n\t}\n\n\tif strings.HasPrefix(src, \"github.com/\") {\n\t\tsrc, rawQuery, _ := strings.Cut(src, \"?\")\n\n\t\tparts := strings.Split(src, \"/\")\n\t\tif len(parts) < 3 {\n\t\t\treturn \"\", false, fmt.Errorf(\n\t\t\t\t\"GitHub URLs should be github.com/username/repo\")\n\t\t}\n\n\t\turlStr := fmt.Sprintf(\"https://%s\", strings.Join(parts[:3], \"/\"))\n\t\turl, err := url.Parse(urlStr)\n\t\tif err != nil {\n\t\t\treturn \"\", true, fmt.Errorf(\"error parsing GitHub URL: %s\", err)\n\t\t}\n\t\turl.RawQuery = rawQuery\n\n\t\tif !strings.HasSuffix(url.Path, \".git\") {\n\t\t\turl.Path += \".git\"\n\t\t}\n\n\t\tif len(parts) > 3 {\n\t\t\turl.Path += \"//\" + strings.Join(parts[3:], \"/\")\n\t\t}\n\n\t\treturn \"git::\" + url.String(), true, nil\n\t}\n\n\treturn \"\", false, nil\n}\n\n// detectBitBucket detects shorthand schemeless references to bitbucket.org and","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getmodules/moduleaddrs/detect_git.go#L36-L72","documentation":"Returned by detectGitHub when url.Parse rejects the synthesized 'https://github.com/<user>/<repo>' URL. Since the parts already passed the length check, a parse failure means the username or repo segment contains characters illegal in a URL host/path. The %s is the url.Parse error.","triggerScenarios":"A GitHub username or repo name with control characters, spaces, or invalid percent-encoding is concatenated into the URL and url.Parse fails.","commonSituations":"Raw spaces or non-ASCII characters in the path; pasted URL with stray characters; malformed query string from a copy mistake.","solutions":["Verify the username/repo contains only valid URL path characters.","Use the explicit git::https:// form with a known-good URL.","URL-encode any unusual characters or, better, rename the repo."],"exampleFix":"# before (space -> parse fails)\nsource = \"github.com/my org/repo\"\n\n# after\nsource = \"github.com/my-org/repo\"","handlingStrategy":"validation","validationCode":"// Reject GitHub sources with URL-illegal characters before detection.\n// func validGitHubChars(user, repo string) error {\n//     for _, s := range []string{user, repo} {\n//         if strings.ContainsAny(s, \" \\t\\n\\r\") { return fmt.Errorf(\"invalid char in %q\", s) }\n//     }\n//     return nil\n// }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid spaces/non-ASCII in GitHub username/repo references.","Re-copy URLs from GitHub rather than typing them.","URL-encode unusual characters or rename the repo."],"tags":["github","url-parsing","encoding"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}