{"record":{"id":"982350262a50e9c2","repo":"golang/go","slug":"s-s-is-missing-module-path-at-revision-s","errorCode":null,"errorMessage":"%s/%s is missing module path at revision %s","messagePattern":"(.+?)/(.+?) is missing module path at revision (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":876,"sourceCode":"\t\t// a replace directive.\n\t\tdir2 := path.Join(r.codeDir, r.pathMajor[1:])\n\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)","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L858-L894","documentation":"findDir (coderepo.go:874-877). The major-subdir go.mod (file2) was read successfully (err2 == nil) but modfile.ModulePath returned an empty string — the file has no `module` directive. Without a declared module path the file cannot be validated for the expected major version.","triggerScenarios":"A /v2/go.mod exists in the repo but is empty, malformed at the top, or simply lacks a `module` line. modfile.ModulePath returns \"\" for files missing the directive.","commonSituations":"Placeholder go.mod committed by mistake; partially generated go.mod; the file was truncated during a mirror sync; go.mod written as a Go directive without the keyword.","solutions":["Open the offending go.mod in the source repo and add a proper `module <path>` directive.","Remove the file if the major-subdir layout is not intended (let the root go.mod win).","Re-tag and update the dependency version."],"exampleFix":"// before: v2/go.mod\n//   go 1.21\n\n// after: v2/go.mod\n//   module example.com/m/v2\n//\n//   go 1.21","handlingStrategy":"validation","validationCode":"// Lint: every committed go.mod must have a module directive.\n// bash:\n//   find . -name go.mod -print0 | xargs -0 -I{} sh -c 'grep -qE \"^module \" \"{}\" || echo \"missing module: {}\"'\n// Go:\n//   path, err := modfile.Parse(...) // ensure Module.Path != \"\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a `module` directive when creating go.mod.","Add a pre-commit hook that rejects go.mod files without a module path.","Run `go mod tidy` after editing go.mod to catch structural problems."],"tags":["go-modules","go-mod","module-path","repository-layout"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}