{"record":{"id":"25086df2cfd3a3a0","repo":"juanfont/headscale","slug":"go-mod-vendor-w","errorCode":null,"errorMessage":"go mod vendor: %w","messagePattern":"go mod vendor: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/vendorhash/main.go","lineNumber":188,"sourceCode":"\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t// `go mod vendor -o` requires the destination to not already exist.\n\terr = os.Remove(out)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdefer os.RemoveAll(out)\n\n\tcmd := exec.CommandContext(ctx, \"go\", \"mod\", \"vendor\", \"-o\", out)\n\n\tcmd.Env = append(os.Environ(), \"GOWORK=off\")\n\tcmd.Stderr = os.Stderr\n\n\terr = cmd.Run()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"go mod vendor: %w\", err)\n\t}\n\n\treturn nardump.SRI(os.DirFS(out))\n}\n\nfunc loadHashes() (FlakeHashes, error) {\n\tvar h FlakeHashes\n\n\tb, err := os.ReadFile(hashesFile)\n\tif err != nil {\n\t\treturn h, err\n\t}\n\n\terr = json.Unmarshal(b, &h)\n\tif err != nil {\n\t\treturn h, fmt.Errorf(\"%s: %w\", hashesFile, err)\n\t}\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/vendorhash/main.go#L170-L206","documentation":"exec of `go mod vendor -o <tmpdir>` failed in the vendorhash tool, which vendors dependencies to hash them (nardump.SRI) for flake reproducibility checks. cmd.Run() returns a non-zero exit when `go` is not found (exec error), the module graph is broken, or module downloads fail. Stderr is wired through to os.Stderr, so the actual go error message is visible in the command output above this wrapper.","triggerScenarios":"Running cmd/vendorhash when `go` is not on PATH; go.mod/go.sum inconsistent (missing go.sum entries, `go mod tidy` needed); module fetch failures via GOPROXY (private modules, proxy down, GONOSUMDB/GOPRIVATE misconfigured); GOWORK=off interacting badly with a workspace setup.","commonSituations":"Running the tool outside `nix develop` where the pinned Go 1.26.1 toolchain is absent; CI without module-cache credentials for private deps; a go.sum updated by hand; GOPROXY=direct with network restrictions.","solutions":["Run `go mod vendor` manually in the repo to see the real error (the tool already pipes stderr)","Ensure Go is installed/on PATH (inside headscale: `nix develop` gives Go 1.26.1)","Fix module issues: `go mod tidy`, verify GOPROXY/GOPRIVATE for private modules, check network to proxy.golang.org","Re-run the vendorhash command once `go mod vendor` succeeds"],"exampleFix":"# before: tool fails, stderr shows 'missing go.sum entry'\ngo run ./cmd/vendorhash\n\n# after\ngo mod tidy && go mod vendor\ngo run ./cmd/vendorhash","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"go\"); err != nil {\n    return fmt.Errorf(\"go toolchain required: %w\", err)\n}\n// dry-run the same operation first; its stderr explains any module problem\nif d, err := exec.Command(\"go\", \"mod\", \"vendor\", \"-o\", os.TempDir()+\"/vh-probe\").CombinedOutput(); err != nil {\n    return fmt.Errorf(\"go mod vendor probe failed: %s\", d)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    var ee *exec.ExitError\n    if errors.As(err, &ee) {\n        // go ran and failed — module/network problem; its stderr was already streamed\n        return \"\", fmt.Errorf(\"go mod vendor (exit %d): %w\", ee.ExitCode(), err)\n    }\n    // go binary itself missing/unusable\n    return \"\", fmt.Errorf(\"go mod vendor: %w\", err)\n}","preventionTips":["Run the tool inside `nix develop` so the pinned Go toolchain is on PATH","Keep go.mod/go.sum consistent (`go mod tidy`) before hashing","Configure GOPROXY/GOPRIVATE correctly for private modules in CI"],"tags":["go-modules","tooling","vendorhash","build"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}