{"record":{"id":"6b9f70b308718dab","repo":"golang/go","slug":"s-has-malformed-module-path-q-s-at-revision-s","errorCode":null,"errorMessage":"%s has malformed module path %q%s at revision %s","messagePattern":"(.+?) has malformed module path %q(.+?) at revision (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":900,"sourceCode":"\t// Not v2/go.mod, so it's either go.mod or nothing. Which is it?\n\tif found1 {\n\t\t// Explicit go.mod with matching major version ok.\n\t\treturn rev, r.codeDir, gomod1, nil\n\t}\n\tif err1 == nil {\n\t\t// Explicit go.mod with non-matching major version disallowed.\n\t\tsuffix := \"\"\n\t\tif file2 != \"\" {\n\t\t\tsuffix = fmt.Sprintf(\" (and ...%s/go.mod does not exist)\", r.pathMajor)\n\t\t}\n\t\tif mpath1 == \"\" {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s is missing module path%s at revision %s\", file1, suffix, rev)\n\t\t}\n\t\tif r.pathMajor != \"\" { // \".v1\", \".v2\" for gopkg.in\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has non-...%s module path %q%s at revision %s\", file1, r.pathMajor, mpath1, suffix, rev)\n\t\t}\n\t\tif _, _, ok := module.SplitPathVersion(mpath1); !ok {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has malformed module path %q%s at revision %s\", file1, mpath1, suffix, rev)\n\t\t}\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has post-%s module path %q%s at revision %s\", file1, semver.Major(version), mpath1, suffix, rev)\n\t}\n\n\tif r.codeDir == \"\" && (r.pathMajor == \"\" || strings.HasPrefix(r.pathMajor, \".\")) {\n\t\t// Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in.\n\t\treturn rev, \"\", nil, nil\n\t}\n\n\t// Implicit go.mod below root of repo or at v2+ disallowed.\n\t// Be clear about possibility of using either location for v2+.\n\tif file2 != \"\" {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"missing %s/go.mod and ...%s/go.mod at revision %s\", r.pathPrefix, r.pathMajor, rev)\n\t}\n\treturn \"\", \"\", nil, fmt.Errorf(\"missing %s/go.mod at revision %s\", r.pathPrefix, rev)\n}\n\n// isMajor reports whether the versions allowed for mpath are compatible with","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L882-L918","documentation":"findDir (coderepo.go:899-901). The root go.mod declares a module path that module.SplitPathVersion cannot parse into prefix + version (returns ok=false). pathMajor is empty (standard module path) so we fall through to the structural validity check, which fails. The declared module path is malformed — missing or non-numeric version segment.","triggerScenarios":"go.mod's `module` directive is something like `module example.com/m@v2` or `module m` (no dot, unparsable) or any path SplitPathVersion rejects.","commonSituations":"Typos in the module path (special characters, missing slashes); module paths with invalid version suffixes; paths copy-pasted from URLs including schemes.","solutions":["Correct the module path in go.mod to a valid Go module path (e.g. `module example.com/m`).","Run `gofmt`/`go mod tidy` on the source repo to catch malformed go.mod early.","Tag a fixed revision and re-resolve."],"exampleFix":"// before: go.mod\n//   module https://example.com/m\n\n// after: go.mod\n//   module example.com/m","handlingStrategy":"validation","validationCode":"// Validate the module path parses cleanly.\n// Go:\npackage main\nimport (\"fmt\"; \"golang.org/x/mod/module\")\nfunc validatePath(p string) error {\n    if _, _, ok := module.SplitPathVersion(p); !ok {\n        return fmt.Errorf(\"malformed module path: %q\", p)\n    }\n    return nil\n}\n// bash lint:\n//   grep -E '^module ' go.mod | grep -vE '^module [a-z0-9./_-]+$' && echo 'suspicious module path'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use plain DNS-style paths for module declarations (no scheme, no port-only segments).","Run `go mod tidy` to catch malformed module paths at edit time.","Add a CI lint rejecting module paths that SplitPathVersion rejects."],"tags":["go-modules","go-mod","module-path","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}