{"record":{"id":"dfaf4b550bdb321b","repo":"golang/go","slug":"invalid-module-path-q","errorCode":null,"errorMessage":"invalid module path %q","messagePattern":"invalid module path %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":72,"sourceCode":"\t// pseudoMajor is the major version prefix to require when generating\n\t// pseudo-versions for this module, derived from the module path. pseudoMajor\n\t// is empty if the module path does not include a version suffix (that is,\n\t// accepts either v0 or v1).\n\tpseudoMajor string\n}\n\n// newCodeRepo returns a Repo that reads the source code for the module with the\n// given path, from the repo stored in code.\n// codeRoot gives the import path corresponding to the root of the repository,\n// and subdir gives the subdirectory within the repo containing the module.\n// If subdir is empty, the module is at the root of the repo.\nfunc newCodeRepo(code codehost.Repo, codeRoot, subdir, path string) (Repo, error) {\n\tif !hasPathPrefix(path, codeRoot) {\n\t\treturn nil, fmt.Errorf(\"mismatched repo: found %s for %s\", codeRoot, path)\n\t}\n\tpathPrefix, pathMajor, ok := module.SplitPathVersion(path)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid module path %q\", path)\n\t}\n\tif codeRoot == path {\n\t\tpathPrefix = path\n\t}\n\tpseudoMajor := module.PathMajorPrefix(pathMajor)\n\n\t// Compute codeDir = bar, the subdirectory within the repo\n\t// corresponding to the module root.\n\t//\n\t// At this point we might have:\n\t//\tpath = github.com/rsc/foo/bar/v2\n\t//\tcodeRoot = github.com/rsc/foo\n\t//\tpathPrefix = github.com/rsc/foo/bar\n\t//\tpathMajor = /v2\n\t//\tpseudoMajor = v2\n\t//\n\t// which gives\n\t//\tcodeDir = bar","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L54-L90","documentation":"newCodeRepo calls module.SplitPathVersion on the module path; if it returns ok==false the path cannot be decomposed into a prefix and version suffix, so the path is syntactically invalid. The %q is the offending path.","triggerScenarios":"module.SplitPathVersion fails — path contains invalid version characters, an unparseable /vN suffix, escapes, or control characters. Indicates a corrupt go.mod, replace directive, or vanity meta tag emitting a malformed path.","commonSituations":"A go.mod with a typo'd module path (e.g. trailing slash, uppercase letters, '/v' followed by non-digit); a vanity server emitting a path with disallowed characters; a replace directive pointing at a relative path leaking into module resolution.","solutions":["Print go.mod and verify the module path follows the Go module path rules (lowercase, dot-separated, optional /vN suffix where N>=2).","Correct the module path in the upstream go.mod and re-tag.","Inspect the go-import meta tag and ensure the advertised path is well-formed.","Use `go mod edit -module=<correct path>` to fix a local module declaration."],"exampleFix":"// before\nmodule github.com/User/Repo  // uppercase letters are invalid\n// error: invalid module path \"github.com/User/Repo\"\n\n// after\nmodule github.com/user/repo","handlingStrategy":"validation","validationCode":"func modulePathValid(path string) bool {\n    _, _, ok := module.SplitPathVersion(path)\n    return ok\n}","typeGuard":"func isValidModulePath(p string) bool {\n    if p == \"\" { return false }\n    if !utf8.ValidString(p) { return false }\n    if strings.ContainsAny(p, \"\\\\ABCDEFGHIJKLMNOPQRSTUVWXYZ\") { return false }\n    _, _, ok := module.SplitPathVersion(p)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Follow Go module path conventions: lowercase, dot-separated, optional /vN (N>=2) suffix.","Lint go.mod files with `go mod verify` and module-path validators in CI.","Never hand-edit the module directive — use `go mod edit -module=`."],"tags":["module-path","validation","go-mod","syntax"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}