{"record":{"id":"fd73932ebf00c5f6","repo":"gohugoio/hugo","slug":"failed-to-map-git-repo-for-module-s-v","errorCode":null,"errorMessage":"failed to map git repo for module %s: %v","messagePattern":"failed to map git repo for module (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/gitinfo.go","lineNumber":176,"sourceCode":"}\n\nfunc (g *gitInfo) loadModuleRepos(cfg gitInfoConfig) error {\n\tfor _, mod := range cfg.Modules {\n\t\tif !isGitModule(mod) {\n\t\t\tcontinue\n\t\t}\n\n\t\tloadGitInfo := sync.OnceValues(func() (*gitmap.GitRepo, error) {\n\t\t\torigin := mod.Origin()\n\n\t\t\tcloneDir, err := ensureClone(cfg, origin)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to clone %s: %v\", origin.URL, err)\n\t\t\t}\n\n\t\t\trepo, err := mapModuleRepo(cfg, cloneDir, origin.Hash)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to map git repo for module %s: %v\", mod.Path(), err)\n\t\t\t}\n\t\t\treturn repo, nil\n\t\t})\n\n\t\tg.moduleRepoLoaders[mod.Dir()] = loadGitInfo\n\t}\n\n\treturn nil\n}\n\n// ensureClone ensures a blobless clone of the module's origin repo exists in the cache.\nfunc ensureClone(cfg gitInfoConfig, origin modules.ModuleOrigin) (string, error) {\n\tkey := \"repo_\" + hashing.XxHashFromStringHexEncoded(origin.URL)\n\tinfo, err := cfg.GitInfoCache.GetOrCreateInfo(key, func(id string) error {\n\t\tcloneDir := cfg.GitInfoCache.AbsFilenameFromID(id)\n\t\tif err := os.MkdirAll(cloneDir, 0o777); err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/gitinfo.go#L158-L194","documentation":"Wraps a failure of mapModuleRepo() for a given module after its clone exists. mapModuleRepo opens the cloned repo at a revision via gitmap; the %s is the module path, %v the mapping error (e.g. revision not found, git command failure).","triggerScenarios":"Raised at gitinfo.go:176 when mapModuleRepo(cfg, cloneDir, origin.Hash) errors — the clone succeeded but resolving the requested revision/hash failed, or the gitmap helper command could not run.","commonSituations":"The module origin's recorded hash was force-pushed away (revision no longer exists in the clone); a shallow/blobless clone missing the referenced commit; gitmap unable to run git due to PATH/exec issues; submodule revision mismatch.","solutions":["Inspect the wrapped %v — usually a 'reference not found' or git command failure naming the revision.","Re-fetch the module: `hugo mod clean` / remove the module + gitinfo cache and rebuild so the latest revision is used.","Confirm the module's origin hash is reachable (git ls-remote <origin>) in a blobless clone context.","Update the module to a commit hash that exists on the remote."],"exampleFix":"// before: module pinned to a deleted commit\n[[imports]]\npath = \"github.com/foo/bar\"\n// hugo.mod pins hash abc123 (force-pushed away)\n\n// after: bump to an existing commit\nhugo mod get github.com/foo/bar@latest","handlingStrategy":"retry","validationCode":"// Pre-check: confirm the referenced revision exists via ls-remote before mapping.\nif out, err := exec.Command(\"git\",\"ls-remote\",originURL,hash).Output(); err != nil || len(out)==0 { return errors.New(\"revision unreachable\") }","typeGuard":null,"tryCatchPattern":"repo, err := mapModuleRepo(cfg, cloneDir, hash)\nif err != nil {\n    // refresh module to latest reachable revision, then retry once\n    _ = hugoModGet(mod.Path()+\"@latest\")\n    repo, err = mapModuleRepo(cfg, cloneDir, newHash)\n}","preventionTips":["Pin modules to durable tags/branches, not ephemeral force-pushed commits.","Run `hugo mod tidy` regularly so revisions stay reachable.","Clear the gitinfo cache when switching branches/PRs in CI."],"tags":["git","modules","gitinfo","revision","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}