{"record":{"id":"0c94435afdf1faf0","repo":"golang/go","slug":"s-s-has-non-s-module-path-q-at-revision-s","errorCode":null,"errorMessage":"%s/%s has non-...%s module path %q at revision %s","messagePattern":"(.+?)/(.+?) has non-\\.\\.\\.(.+?) module path %q at revision (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":878,"sourceCode":"\t\tfile2 = path.Join(dir2, \"go.mod\")\n\t\tgomod2, err2 := r.code.ReadFile(ctx, rev, file2, codehost.MaxGoMod)\n\t\tif err2 != nil && !os.IsNotExist(err2) {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"reading %s/%s at revision %s: %v\", r.codeRoot, file2, rev, err2)\n\t\t}\n\t\tmpath2 := modfile.ModulePath(gomod2)\n\t\tfound2 := err2 == nil && isMajor(mpath2, r.pathMajor)\n\n\t\tif found1 && found2 {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s/%s and ...%s/go.mod both have ...%s module paths at revision %s\", r.pathPrefix, file1, r.pathMajor, r.pathMajor, rev)\n\t\t}\n\t\tif found2 {\n\t\t\treturn rev, dir2, gomod2, nil\n\t\t}\n\t\tif err2 == nil {\n\t\t\tif mpath2 == \"\" {\n\t\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s/%s is missing module path at revision %s\", r.codeRoot, file2, rev)\n\t\t\t}\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s/%s has non-...%s module path %q at revision %s\", r.codeRoot, file2, r.pathMajor, mpath2, rev)\n\t\t}\n\t}\n\n\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","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L860-L896","documentation":"findDir (coderepo.go:877-879). The major-subdir go.mod (file2) was read successfully and declares a module path (mpath2 != \"\"), but isMajor(mpath2, pathMajor) is false — the declared path's major-version suffix does not match the expected pathMajor (e.g. /v2/go.mod says `module example.com/m/v3`).","triggerScenarios":"The major subdirectory go.mod declares a different major version than its location implies: /v2/go.mod with `module …/v3`, or /v3/go.mod with `module …/v2`, or any non-matching suffix.","commonSituations":"Renaming a major-version subdirectory without updating the module directive; copy-pasting go.mod between major branches; misconfigured multi-module repos.","solutions":["Make the module path in the subdirectory go.mod match the directory's major suffix (e.g. `v2/go.mod` must declare `module …/v2`).","If the subdirectory is the wrong location, move it to match the declared module path.","Re-tag and re-resolve after the fix."],"exampleFix":"// before: v2/go.mod\n//   module example.com/m/v3\n//\n// after: v2/go.mod\n//   module example.com/m/v2","handlingStrategy":"validation","validationCode":"// The module path in <subdir>/go.mod must match the subdir's major suffix.\n// bash:\n//   # for v2/go.mod, the module line must end in /v2\n//   grep -H '^module ' v*/go.mod\n// CI check (one-liner):\n//   for f in v*/go.mod; do major=$(basename \"$(dirname \"$f\")\"); \\\n//     grep -qE \"^module .+/${major}$\" \"$f\" || echo \"mismatch in $f\"; done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep directory name and module major suffix in sync (v2 dir <-> /v2 path).","Add a CI lint that cross-checks directory vs declared major version.","When renaming a major subdirectory, update its go.mod in the same commit."],"tags":["go-modules","go-mod","module-path","major-version"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}