hashicorp/terraform · error
Error parsing URL: %s
Error message
Error parsing URL: %s
What it means
Raised in detectRemoteSourceShorthands (internal/getmodules/moduleaddrs/detect_remote_shorthands.go:70). When a shorthand detector (GitHub, BitBucket, S3, GCS, etc.) succeeds and a subdirectory was detected or supplied, the result is re-parsed with url.Parse so the subdir can be appended to the path. If that reconstructed string fails to parse, this error is returned. Because detectors build the URL from controlled components, this path is rarely hit and usually signals an unusual character in the source.
Source
Thrown at internal/getmodules/moduleaddrs/detect_remote_shorthands.go:70
var detectForce string
detectForce, result = getForcedSourceType(result)
result, detectSubdir := SplitPackageSubdir(result)
// If we have a subdir from the detection, then prepend it to our
// requested subdir.
if detectSubdir != "" {
if subDir != "" {
subDir = filepath.Join(detectSubdir, subDir)
} else {
subDir = detectSubdir
}
}
if subDir != "" {
u, err := url.Parse(result)
if err != nil {
return "", fmt.Errorf("Error parsing URL: %s", err)
}
u.Path += "//" + subDir
// a subdir may contain wildcards, but in order to support them we
// have to ensure the path isn't escaped.
u.RawPath = u.Path
result = u.String()
}
// Preserve the forced getter if it exists. We try to use the
// original set force first, followed by any force set by the
// detector.
if getForce != "" {
result = fmt.Sprintf("%s::%s", getForce, result)
} else if detectForce != "" {
result = fmt.Sprintf("%s::%s", detectForce, result)
}View on GitHub (pinned to c9def3e214)
Solutions
- Replace the shorthand with a fully-qualified URL that includes the scheme (https://...) so the detector/re-parse step is bypassed.
- Remove or escape special characters (spaces, control chars) in the subdir portion of the address.
- If the source looks valid, simplify by dropping the '//subdir' part and test the base package address in isolation to isolate the bad segment.
Example fix
// before
module "x" { source = "github.com/user/repo//sub dir" }
// after
module "x" { source = "github.com/user/repo//sub-dir" } Defensive patterns
Strategy: try-catch
Try / catch
result, err := moduleaddrs.DetectRemoteSourceShorthands(src)
if err != nil {
// Re-parse failed after a detector ran; fall back to a canonical URL.
if u, e := url.Parse(src); e == nil && u.Scheme != "" {
result = src
} else {
return err
}
} Prevention
- Use fully-qualified URLs with an explicit scheme to bypass shorthand detection entirely.
- Avoid special characters (spaces, control chars) in repo names and subdir segments.
- Keep subdir segments simple and URL-safe.
When it happens
Trigger: A shorthand source (e.g. github.com/user/repo//subdir) where the detector-produced base URL plus an embedded subdir combine into a string url.Parse rejects, such as an unescaped space or control character in the repo/subdir portion that survived the detector but breaks re-parse.
Common situations: A module source with a subdir containing spaces or non-ASCII characters without escaping; copy-paste artifacts in the source string; rare detector edge cases.
Related errors
- URL is not a valid GCS URL
- error parsing GCS URL: %s
- GitHub URLs should be github.com/username/repo
- error parsing GitHub URL: %s
- error parsing BitBucket URL: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/077310f8524796cb.
Report an issue: GitHub.