{"record":{"id":"80f4a59ed10375be","repo":"golang/go","slug":"s-w-80f4a5","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/load.go","lineNumber":1218,"sourceCode":"\n\t\t// We ran updateRequirements before resolving missing imports and it didn't\n\t\t// make any changes, so we know that the requirement graph is already\n\t\t// consistent with ld.pkgs: we don't need to pass ld.pkgs to updateRoots\n\t\t// again. (That would waste time looking for changes that we have already\n\t\t// applied.)\n\t\tvar noPkgs []*loadPkg\n\t\t// We also know that we're going to call updateRequirements again next\n\t\t// iteration so we don't need to also update it here. (That would waste time\n\t\t// computing a \"direct\" map that we'll have to recompute later anyway.)\n\t\tdirect := pld.requirements.direct\n\t\trs, err := updateRoots(ld, ctx, direct, pld.requirements, noPkgs, toAdd, pld.AssumeRootsImported)\n\t\tif err != nil {\n\t\t\t// If an error was found in a newly added module, report the package\n\t\t\t// import stack instead of the module requirement stack. Packages\n\t\t\t// are more descriptive.\n\t\t\tif err, ok := err.(*mvs.BuildListError); ok {\n\t\t\t\tif pkg := modAddedBy[err.Module()]; pkg != nil {\n\t\t\t\t\tpld.error(fmt.Errorf(\"%s: %w\", pkg.stackText(), err.Err))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tpld.error(err)\n\t\t\tbreak\n\t\t}\n\t\tif slices.Equal(rs.rootModules, pld.requirements.rootModules) {\n\t\t\t// Something is deeply wrong. resolveMissingImports gave us a non-empty\n\t\t\t// set of modules to add to the graph, but adding those modules had no\n\t\t\t// effect — either they were already in the graph, or updateRoots did not\n\t\t\t// add them as requested.\n\t\t\tpanic(fmt.Sprintf(\"internal error: adding %v to module graph had no effect on root requirements (%v)\", toAdd, rs.rootModules))\n\t\t}\n\t\tpld.requirements = rs\n\t}\n\tpld.exitIfErrors(ctx)\n\n\t// Tidy the build list, if applicable, before we report errors.","sourceCodeStart":1200,"sourceCodeEnd":1236,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/load.go#L1200-L1236","documentation":"Thrown in the package-loading loop (load.go:1218) when updateRoots returns an error that is a *mvs.BuildListError and the failing module was one newly added (tracked in modAddedBy). Instead of reporting the raw module-level error, it wraps it with the importing package's stack text (pkg.stackText()) so the user sees the import chain that led to the broken module. The %w verb preserves error unwrapping.","triggerScenarios":"During package loading, a newly-added module requirement fails to build its dependency graph (BuildListError), and that module was added because some package imported it. The modAddedBy map links the module to the importing package, enabling a richer error message.","commonSituations":"'go get' or 'go mod tidy' adds a dependency whose transitive graph is broken (missing module, checksum failure, etc.). The error surfaces the import path that triggered the addition, helping locate the offending import.","solutions":["Read the import stack in the error to identify which package import triggered the failing module addition.","Fix the root module issue: run 'go get' on the specific failing module, check network/proxy, or verify checksums.","If the import is unintended, remove it from your source and re-run 'go mod tidy'."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// When loading packages, detect BuildListError and surface the import stack.\nerr := loadPackages(ld, ctx)\nif err != nil {\n    var ble *mvs.BuildListError\n    if errors.As(err, &ble) {\n        // The error already includes the package import stack;\n        // report ble.Module() and ble.Err for diagnostics.\n        log.Printf(\"module %s failed: %v\", ble.Module(), ble.Err)\n    }\n}","preventionTips":["Run 'go mod tidy' regularly to keep requirements consistent with imports.","Review import stacks in errors to find the triggering import.","Pin dependencies with exact versions to avoid unexpected graph changes."],"tags":["module-graph","build-list-error","import-stack","go-mod-tidy"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}