{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getmodules/moduleaddrs/detect_git.go#L64-L100","documentation":"Returned by detectBitBucket when url.Parse rejects 'https://bitbucket.org/<src>'. Unlike GitHub, BitBucket detection does no length check; any string prefixed with 'bitbucket.org/' is parsed directly, so failure is purely about invalid characters in the path/query. The %s is the url.Parse error.","triggerScenarios":"A bitbucket.org source string contains control characters, spaces, or malformed percent-encoding in the path or query, causing url.Parse to fail.","commonSituations":"Whitespace or non-ASCII pasted into the source; broken query/ref parameter; copy from a rich-text source injecting odd characters.","solutions":["Sanitize the source to valid URL characters.","Use the explicit git::https://bitbucket.org/USER/REPO form with a verified URL.","Re-copy the URL from the Bitbucket UI to remove stray characters."],"exampleFix":"# before\nsource = \"bitbucket.org/my org/repo\"\n\n# after\nsource = \"bitbucket.org/my-org/repo\"","handlingStrategy":"validation","validationCode":"// Pre-parse any bitbucket.org/ source to catch bad URLs early.\n// func precheckBitbucket(src string) error {\n//     if !strings.HasPrefix(src, \"bitbucket.org/\") { return nil }\n//     _, err := url.Parse(\"https://\" + src)\n//     return err\n// }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy Bitbucket URLs from the repository page.","Strip whitespace and rich-text artifacts before pasting.","Prefer the explicit git::https://bitbucket.org/... form."],"tags":["bitbucket","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"}