hashicorp/terraform · error
error parsing BitBucket URL
Error message
error parsing BitBucket URL: %s
What it means
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.
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.
Example fix
# before source = "bitbucket.org/my org/repo" # after source = "bitbucket.org/my-org/repo"
Defensive patterns
Strategy: validation
Validate before calling
// Pre-parse any bitbucket.org/ source to catch bad URLs early.
// func precheckBitbucket(src string) error {
// if !strings.HasPrefix(src, "bitbucket.org/") { return nil }
// _, err := url.Parse("https://" + src)
// return err
// } Prevention
- Copy Bitbucket URLs from the repository page.
- Strip whitespace and rich-text artifacts before pasting.
- Prefer the explicit git::https://bitbucket.org/... form.
When it happens
Trigger: A bitbucket.org source string contains control characters, spaces, or malformed percent-encoding in the path or query, causing url.Parse to fail.
Common situations: Whitespace or non-ASCII pasted into the source; broken query/ref parameter; copy from a rich-text source injecting odd characters.
Related errors
- error parsing GCS URL
- error parsing GitHub URL
- error parsing S3 URL
- error parsing Git SSH URL
- Error parsing URL
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/3e874d81ef5a938e.
Report an issue: GitHub.
Appendix: source
Thrown at internal/getmodules/moduleaddrs/detect_git.go:82
}
return "git::" + url.String(), true, nil
}
return "", false, nil
}
// detectBitBucket detects shorthand schemeless references to bitbucket.org and
// translates them into git HTTP source addresses.
func detectBitBucket(src string) (string, bool, error) {
if len(src) == 0 {
return "", false, nil
}
if strings.HasPrefix(src, "bitbucket.org/") {
u, err := url.Parse("https://" + src)
if err != nil {
return "", true, fmt.Errorf("error parsing BitBucket URL: %s", err)
}
// NOTE: A long, long time ago bitbucket.org repositories could
// potentially be either Git or Mercurial repositories and we would've
// needed to make an API call here to know which to generate.
//
// Thankfully BitBucket now only supports Git, and so we can just
// assume all bitbucket.org strings are trying to refer to Git
// repositories.
if !strings.HasSuffix(u.Path, ".git") {
u.Path += ".git"
}
return "git::" + u.String(), true, nil
}
return "", false, nilView on GitHub (pinned to d32a084675)