{"record":{"id":"5cacf97c716d17c1","repo":"golang/go","slug":"s-is-missing-module-path-s-at-revision-s","errorCode":null,"errorMessage":"%s is missing module path%s 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":894,"sourceCode":"\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\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 != \"\" {","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L876-L912","documentation":"findDir (coderepo.go:887-895). The root go.mod (file1) was read successfully (err1 == nil) but found1 is false AND mpath1 is empty. found1 false means the major version did not match; the inner check `mpath1 == \"\"` then reports that the root go.mod has no module directive at all. The optional suffix notes whether the major-subdir go.mod was also missing.","triggerScenarios":"A root go.mod exists at the revision but contains no `module` line (modfile.ModulePath returns \"\"). Common with stub go.mod files committed for tooling purposes.","commonSituations":"Committed go.mod with only `go 1.21` and no module directive; partially migrated legacy repos; go.mod generated by an IDE that omitted the module line.","solutions":["Add a `module <path>` directive to the root go.mod in the source repo.","If the module is meant to live in a major subdirectory, remove the bogus root go.mod so file2 is used.","Tag a corrected revision and update the dependency."],"exampleFix":"// before: go.mod\n//   go 1.21\n\n// after: go.mod\n//   module example.com/m\n//\n//   go 1.21","handlingStrategy":"validation","validationCode":"// Same lint as 993 applied to the root go.mod.\n// bash:\n//   grep -qE '^module ' go.mod || echo 'root go.mod missing module directive'\n// Go:\n//   if modfile.ModulePath(gomod1) == \"\" { return errors.New(\"missing module path\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never commit a go.mod without a module directive.","Add a pre-commit hook validating go.mod structure.","Run `go build ./...` locally before tagging a release."],"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"}