{"record":{"id":"284ee65824db202a","repo":"golang/go","slug":"parsing-s-v-284ee6","errorCode":null,"errorMessage":"parsing %s: %v","messagePattern":"parsing (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/modfile.go","lineNumber":718,"sourceCode":"\t\t// command-line-arguments module, which rawGoModData cannot read a go.mod for.\n\t\treturn &modFileSummary{module: m}, nil\n\t} else if m.Version == \"\" && ld.inWorkspaceMode() && ld.MainModules.Contains(m.Path) {\n\t\t// When go get uses EnterWorkspace to check that the workspace loads properly,\n\t\t// it will update the contents of the workspace module's modfile in memory. To use the updated\n\t\t// contents of the modfile when doing the load, don't read from disk and instead\n\t\t// recompute a summary using the updated contents of the modfile.\n\t\tif mf := ld.MainModules.ModFile(m); mf != nil {\n\t\t\treturn summaryFromModFile(m, ld.MainModules.modFiles[m])\n\t\t}\n\t}\n\treturn rawGoModSummaryCache.Do(m, func() (*modFileSummary, error) {\n\t\tname, data, err := rawGoModData(ld, m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tf, err := modfile.ParseLax(name, data, nil)\n\t\tif err != nil {\n\t\t\treturn nil, module.VersionError(m, fmt.Errorf(\"parsing %s: %v\", base.ShortPath(name), err))\n\t\t}\n\t\treturn summaryFromModFile(m, f)\n\t})\n}\n\nfunc summaryFromModFile(m module.Version, f *modfile.File) (*modFileSummary, error) {\n\tsummary := new(modFileSummary)\n\tif f.Module != nil {\n\t\tsummary.module = f.Module.Mod\n\t\tsummary.deprecated = f.Module.Deprecated\n\t}\n\tif f.Go != nil {\n\t\trawGoVersion.LoadOrStore(m, f.Go.Version)\n\t\tsummary.goVersion = f.Go.Version\n\t\tsummary.pruning = pruningForGoVersion(f.Go.Version)\n\t} else {\n\t\tsummary.pruning = unpruned\n\t}","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/modfile.go#L700-L736","documentation":"Returned from rawGoModSummary when modfile.ParseLax fails on a dependency's go.mod file (the bytes fetched from the proxy or read from a replacement). It is wrapped in module.VersionError so the offending module@version is identified. ParseLax is lenient (it permits missing go directives), so failure here means a structurally broken go.mod.","triggerScenarios":"Resolving the module graph for a dependency whose published go.mod is malformed: unclosed parentheses, bad quoting, unknown directive tokens, or invalid version syntax that even lax parsing rejects.","commonSituations":"A module author published a corrupt go.mod (bad tag, truncated upload); a module proxy served partial/corrupt content; a replace points at a hand-edited go.mod with a syntax error; tampered cache.","solutions":["Read the file:line in the wrapped error to locate the syntax problem in the dependency's go.mod.","If it is a replace target you control, fix the go.mod syntax there.","Upgrade or downgrade the offending module to a version with a valid go.mod: 'go get <module>@<known-good-version>'.","Clear the cache and retry: 'go clean -modcache' (forces re-download)."],"exampleFix":"// before\n// error: parsing go.mod: example.com/bad@v1.0.0/go.mod:3: unknown directive 'dep'\n\n// after: pin a known-good version or fix the replaced file\n$ go get example.com/bad@v0.9.0","handlingStrategy":"fallback","validationCode":"// Pre-validate that a dependency's go.mod is parseable before adding it:\n//   go mod download <module>@<version>\n//   go list -m -json <module>@<version>  // fails if go.mod is corrupt","typeGuard":null,"tryCatchPattern":"// When resolving the graph, isolate a single bad module without failing the whole build:\n//   for _, m := range modules {\n//       if _, err := rawGoModSummary(ld, m); err != nil {\n//           if strings.Contains(err.Error(), \"parsing\") { badMods = append(badMods, m); continue }\n//           return err\n//       }\n//   }","preventionTips":["Pin dependencies to released versions known to have valid go.mod files.","Run 'go mod verify' and 'go mod download' in CI to detect corrupt published go.mod early.","Avoid replacing to a directory whose go.mod you hand-edit; run 'go mod edit -fmt' on it."],"tags":["go-modules","module-graph","go-mod","parse-error","go-modfile"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}