{"record":{"id":"33cfe671439302da","repo":"gohugoio/hugo","slug":"invalid-modules-list-q","errorCode":null,"errorMessage":"invalid modules list: %q","messagePattern":"invalid modules list: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":625,"sourceCode":"\n\t\treturn err\n\t}\n\n\tdefer f.Close()\n\n\tscanner := bufio.NewScanner(f)\n\n\tfor scanner.Scan() {\n\t\t// # github.com/alecthomas/chroma v0.6.3\n\t\tline := scanner.Text()\n\t\tline = strings.Trim(line, \"# \")\n\t\tline = strings.TrimSpace(line)\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tparts := strings.Fields(line)\n\t\tif len(parts) != 2 {\n\t\t\treturn fmt.Errorf(\"invalid modules list: %q\", filename)\n\t\t}\n\t\tpath := parts[0]\n\n\t\tshouldAdd := c.Client.moduleConfig.VendorClosest\n\n\t\tif !shouldAdd {\n\t\t\tif _, found := c.vendored[path]; !found {\n\t\t\t\tshouldAdd = true\n\t\t\t}\n\t\t}\n\n\t\tif shouldAdd {\n\t\t\tc.vendored[path] = vendoredModule{\n\t\t\t\tOwner:   owner,\n\t\t\t\tDir:     filepath.Join(vendorDir, path),\n\t\t\t\tVersion: parts[1],\n\t\t\t}\n\t\t}","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L607-L643","documentation":"collectModulesTXT parses _vendor/modules.txt line by line; each line must have exactly two whitespace fields (module path and version). Any line with != 2 fields aborts vendor parsing with the offending filename. The file is normally generated by `go mod vendor`, so a malformed line implies manual edits or corruption.","triggerScenarios":"A _vendor/modules.txt containing a comment line that wasn't stripped, a wrapped/truncated line, a hand-merged file with stray text, or a vendor dir produced by a tool that diverges from go's format.","commonSituations":"Manually editing modules.txt to add/remove a vendored dep, a bad merge conflict resolution leaving a 3-field or 1-field line, or a pre-Go-1.14 vendor format.","solutions":["Regenerate the vendor directory: `hugo mod vendor` (or `go mod vendor`) to produce a canonical modules.txt.","If you must hand-edit, ensure every non-comment line is exactly `path version`.","Inspect the file: `cat _vendor/modules.txt` and find the line with the wrong field count.","Remove the stale _vendor dir entirely if vendoring is not intended (`rm -rf _vendor`)."],"exampleFix":"// before: a malformed line in _vendor/modules.txt\n# github.com/x/y v1.2.3 extra-note\ngithub.com/x/y v1.2.3\n// after: regenerate\nrm -rf _vendor && hugo mod vendor","handlingStrategy":"validation","validationCode":"// Lint a vendor/modules.txt before Hugo parses it\nimport (\"bufio\"; \"os\"; \"strings\")\n\nfunc lintModulesTxt(path string) error {\n  f, err := os.Open(path)\n  if err != nil { return err }\n  defer f.Close()\n  s := bufio.NewScanner(f)\n  for s.Scan() {\n    line := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(s.Text()), \"# \"))\n    if line == \"\" { continue }\n    if len(strings.Fields(line)) != 2 { return fmt.Errorf(\"bad line: %q\", line) }\n  }\n  return s.Err()\n}","typeGuard":"null","tryCatchPattern":"// On 'invalid modules list:', regenerate vendor/ rather than patching by hand.","preventionTips":["Generate _vendor only via `hugo mod vendor` / `go mod vendor`.","Never hand-edit modules.txt; re-vendor after dep changes.","In CI, fail if modules.txt differs from regenerated output."],"tags":["modules","vendor","config","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}