{"record":{"id":"077310f8524796cb","repo":"hashicorp/terraform","slug":"error-parsing-url-s","errorCode":null,"errorMessage":"Error parsing URL: %s","messagePattern":"Error parsing URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getmodules/moduleaddrs/detect_remote_shorthands.go","lineNumber":70,"sourceCode":"\n\t\tvar detectForce string\n\t\tdetectForce, result = getForcedSourceType(result)\n\t\tresult, detectSubdir := SplitPackageSubdir(result)\n\n\t\t// If we have a subdir from the detection, then prepend it to our\n\t\t// requested subdir.\n\t\tif detectSubdir != \"\" {\n\t\t\tif subDir != \"\" {\n\t\t\t\tsubDir = filepath.Join(detectSubdir, subDir)\n\t\t\t} else {\n\t\t\t\tsubDir = detectSubdir\n\t\t\t}\n\t\t}\n\n\t\tif subDir != \"\" {\n\t\t\tu, err := url.Parse(result)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"Error parsing URL: %s\", err)\n\t\t\t}\n\t\t\tu.Path += \"//\" + subDir\n\n\t\t\t// a subdir may contain wildcards, but in order to support them we\n\t\t\t// have to ensure the path isn't escaped.\n\t\t\tu.RawPath = u.Path\n\n\t\t\tresult = u.String()\n\t\t}\n\n\t\t// Preserve the forced getter if it exists. We try to use the\n\t\t// original set force first, followed by any force set by the\n\t\t// detector.\n\t\tif getForce != \"\" {\n\t\t\tresult = fmt.Sprintf(\"%s::%s\", getForce, result)\n\t\t} else if detectForce != \"\" {\n\t\t\tresult = fmt.Sprintf(\"%s::%s\", detectForce, result)\n\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getmodules/moduleaddrs/detect_remote_shorthands.go#L52-L88","documentation":"Returned by the remote-shorthand detector when, after a subdir has been appended to the detected result ('<result>//<subDir>'), url.Parse fails on the combined string. The subdir join produces u.Path = old + '//' + subDir; if the result is not a valid URL the parse errors. The %s is the url.Parse error.","triggerScenarios":"A detected remote source combined with a user subdir yields an invalid URL — typically because the subdir or the detected base contains characters that break URL parsing once concatenated.","commonSituations":"Subdir containing spaces/control chars; detector returned a result with an unexpected scheme; nested double-slash or encoding artifacts from copy-paste.","solutions":["Sanitize the subdir portion of the source to valid URL path characters.","Specify the source without a subdir first to confirm the base parses, then add '//subdir'.","Use the fully-qualified form (git::https://...//subdir) to avoid detector ambiguity."],"exampleFix":"# before (space in subdir)\nsource = \"github.com/org/repo//my module\"\n\n# after\nsource = \"github.com/org/repo//my-module\"","handlingStrategy":"validation","validationCode":"// Pre-validate that base + subdir parses before invoking the detector.\n// func precheckRemoteWithSubdir(base, subdir string) error {\n//     u, err := url.Parse(base)\n//     if err != nil { return err }\n//     u.Path += \"//\" + subdir\n//     _, err = url.Parse(u.String())\n//     return err\n// }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep subdir components free of spaces and control characters.","Confirm the base URL parses before appending '//subdir'.","Use fully-qualified scheme-prefixed sources for non-trivial addresses."],"tags":["module-address","url-parsing","subdir"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}