{"record":{"id":"929be495abc8fd67","repo":"golang/go","slug":"not-in-workspace-mode-but-number-of-indexes-is-v","errorCode":null,"errorMessage":"not in workspace mode but number of indexes is %v, not 1","messagePattern":"not in workspace mode but number of indexes is (.+?), not 1","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cmd/go/internal/modload/vendor.go","lineNumber":159,"sourceCode":"// go 1.14) or at least does not contradict (go 1.13 or earlier) the\n// requirements and replacements listed in the main module's go.mod file.\nfunc checkVendorConsistency(ld *Loader, indexes []*modFileIndex, modFiles []*modfile.File) {\n\t// readVendorList only needs the main module to get the directory\n\t// the vendor directory is in.\n\treadVendorList(VendorDir(ld))\n\n\tif len(modFiles) < 1 {\n\t\t// We should never get here if there are zero modfiles. Either\n\t\t// we're in single module mode and there's a single module, or\n\t\t// we're in workspace mode, and we fail earlier reporting that\n\t\t// \"no modules were found in the current workspace\".\n\t\tpanic(\"checkVendorConsistency called with zero modfiles\")\n\t}\n\n\tpre114 := false\n\tif !ld.inWorkspaceMode() { // workspace mode was added after Go 1.14\n\t\tif len(indexes) != 1 {\n\t\t\tpanic(fmt.Errorf(\"not in workspace mode but number of indexes is %v, not 1\", len(indexes)))\n\t\t}\n\t\tindex := indexes[0]\n\t\tif gover.Compare(index.goVersion, \"1.14\") < 0 {\n\t\t\t// Go versions before 1.14 did not include enough information in\n\t\t\t// vendor/modules.txt to check for consistency.\n\t\t\t// If we know that we're on an earlier version, relax the consistency check.\n\t\t\tpre114 = true\n\t\t}\n\t}\n\n\tvendErrors := new(strings.Builder)\n\tvendErrorf := func(mod module.Version, format string, args ...any) {\n\t\tdetail := fmt.Sprintf(format, args...)\n\t\tif mod.Version == \"\" {\n\t\t\tfmt.Fprintf(vendErrors, \"\\n\\t%s: %s\", mod.Path, detail)\n\t\t} else {\n\t\t\tfmt.Fprintf(vendErrors, \"\\n\\t%s@%s: %s\", mod.Path, mod.Version, detail)\n\t\t}","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/vendor.go#L141-L177","documentation":"This is a panic, not a returned error. checkVendorConsistency panics when it is not in workspace mode yet receives more (or fewer) than one modFileIndex. In single-module mode exactly one index is expected; any other count means an internal invariant of the loader was violated.","triggerScenarios":"Vendor consistency checking runs outside workspace mode but the loader hands it a number of indexes != 1. Reachable only through a bug in loader state management or a malformed invocation path.","commonSituations":"Not user-triggered in normal operation. Could surface from experimental toolchain builds, corrupted build state, or a regression in cmd/go that mis-counts modules outside workspace mode.","solutions":["This indicates a Go toolchain bug — report at https://go.dev/issue with the panic stack and reproduction.","As a workaround, switch into or out of workspace mode explicitly ('go work' usage) to see if it changes the index count.","Run 'go clean -modcache' and 'rm vendor/modules.txt' then 'go mod vendor' to rebuild vendor state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Not user-preventable. Sanity-check loader state in tooling before calling vendor checks:\n//   if !ld.inWorkspaceMode() && len(indexes) != 1 { panic(\"loader invariant violated\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat this panic as a toolchain bug; report it with a reproduction at https://go.dev/issue.","Keep vendor/modules.txt in sync by running 'go mod vendor' after dependency changes.","Avoid mixing workspace and non-workspace invocations in the same process."],"tags":["go-modules","panic","internal-error","vendor","workspace"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}