{"record":{"id":"3e874d81ef5a938e","repo":"hashicorp/terraform","slug":"error-parsing-bitbucket-url-s","errorCode":null,"errorMessage":"error parsing BitBucket URL: %s","messagePattern":"error parsing BitBucket URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getmodules/moduleaddrs/detect_git.go","lineNumber":82,"sourceCode":"\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\n// translates them into git HTTP source addresses.\nfunc detectBitBucket(src string) (string, bool, error) {\n\tif len(src) == 0 {\n\t\treturn \"\", false, nil\n\t}\n\n\tif strings.HasPrefix(src, \"bitbucket.org/\") {\n\t\tu, err := url.Parse(\"https://\" + src)\n\t\tif err != nil {\n\t\t\treturn \"\", true, fmt.Errorf(\"error parsing BitBucket URL: %s\", err)\n\t\t}\n\n\t\t// NOTE: A long, long time ago bitbucket.org repositories could\n\t\t// potentially be either Git or Mercurial repositories and we would've\n\t\t// needed to make an API call here to know which to generate.\n\t\t//\n\t\t// Thankfully BitBucket now only supports Git, and so we can just\n\t\t// assume all bitbucket.org strings are trying to refer to Git\n\t\t// repositories.\n\n\t\tif !strings.HasSuffix(u.Path, \".git\") {\n\t\t\tu.Path += \".git\"\n\t\t}\n\n\t\treturn \"git::\" + u.String(), true, nil\n\t}\n\n\treturn \"\", false, nil","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getmodules/moduleaddrs/detect_git.go#L64-L100","documentation":"Returned by detectBitBucket (detect_git.go:82) when url.Parse fails after prepending 'https://' to a bitbucket.org/ source string. detectBitBucket assumes the remainder after 'bitbucket.org/' forms a valid https URL; if it contains characters net/url.Parse cannot handle, parsing fails and this error wraps the underlying parse error.","triggerScenarios":"A module source starting with 'bitbucket.org/' whose remainder contains characters that make 'https://' + src unparseable (spaces, control characters, malformed percent-encoding, embedded newlines).","commonSituations":"Copy-paste of a BitBucket URL with stray whitespace, quotes, or special characters in the repo/path. Non-ASCII path segments. A source string accidentally including a scheme or malformed query string.","solutions":["Trim whitespace and ensure only valid URL characters appear in the source after 'bitbucket.org/'.","URL-encode special characters in repo/path segments.","Use the explicit git URL form: source = \"git::https://bitbucket.org/user/repo.git\".","Inspect the parse error detail in the message to find the offending character."],"exampleFix":"# before — stray space in repo path\nsource = \"bitbucket.org/user/my repo\"\n\n# after — valid bitbucket shorthand\nsource = \"bitbucket.org/user/my-repo\"","handlingStrategy":"validation","validationCode":"// Pre-parse the assembled BitBucket URL to catch bad characters\nfunc bitbucketURLParses(src string) bool {\n    if !strings.HasPrefix(src, \"bitbucket.org/\") {\n        return true\n    }\n    _, err := url.Parse(\"https://\" + src)\n    return err == nil\n}","typeGuard":"func bitbucketURLParses(src string) bool {\n    if !strings.HasPrefix(src, \"bitbucket.org/\") {\n        return false\n    }\n    _, err := url.Parse(\"https://\" + src)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Trim whitespace and stray characters from bitbucket.org source strings.","URL-encode special characters in repo/path segments.","Use the explicit git::https://bitbucket.org/user/repo.git form for non-trivial paths."],"tags":["getmodules","bitbucket","module-source","url-parsing","modules"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}