{"record":{"id":"f7a470e383d711a7","repo":"gohugoio/hugo","slug":"git-clone-s-w-s","errorCode":null,"errorMessage":"git clone %s: %w: %s","messagePattern":"git clone (.+?): %w: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/gitinfo.go","lineNumber":214,"sourceCode":"\t\tvar stderr bytes.Buffer\n\t\targs := []any{\n\t\t\t\"clone\",\n\t\t\t\"--filter=blob:none\",\n\t\t\t\"--no-checkout\",\n\t\t\torigin.URL,\n\t\t\tcloneDir,\n\t\t\thexec.WithStdout(io.Discard),\n\t\t\thexec.WithStderr(&stderr),\n\t\t}\n\n\t\tcfg.Logger.Infof(\"Cloning gitinfo for repo %s into cache\", origin.URL)\n\n\t\tcmd, err := cfg.Deps.ExecHelper.New(\"git\", args...)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"git clone: %w\", err)\n\t\t}\n\t\tif err := cmd.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"git clone %s: %w: %s\", origin.URL, err, stderr.String())\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn cfg.GitInfoCache.AbsFilenameFromID(info.Name), nil\n}\n\nfunc mapModuleRepo(cfg gitInfoConfig, repoDir, revision string) (*gitmap.GitRepo, error) {\n\topts := gitmap.Options{\n\t\tRepository: repoDir,\n\t\tRevision:   revision,\n\t\tGetGitCommandFunc: func(stdout, stderr io.Writer, args ...string) (gitmap.Runner, error) {\n\t\t\tvar argsv []any\n\t\t\tfor _, arg := range args {\n\t\t\t\targsv = append(argsv, arg)\n\t\t\t}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/gitinfo.go#L196-L232","documentation":"Returned when the git clone command actually runs but exits non-zero. The message includes the origin URL (%s), the execution error (%w), and the captured stderr (%s) — so the real git failure (auth, network, not-found) is in stderr.","triggerScenarios":"Raised at gitinfo.go:214 when cmd.Run() fails for the 'git clone --filter=blob:none --no-checkout <url> <dir>' command. stderr is captured via WithStderr into the message for diagnostics.","commonSituations":"Repository does not exist or URL is wrong (404/Repository not found); authentication required and not provided (403/Permission denied); rate limiting or network/firewall blocking github.com; destination dir already a non-empty git repo from a corrupt cache.","solutions":["Read the trailing stderr in the message — it states the exact git failure (auth, not-found, network).","Provide git credentials for private repos (SSH key, token, or git url.insteadOf rewrite).","Clear the gitinfo cache dir for that repo (HUGO_CACHEDIR/repo_<hash>) and retry to rule out a corrupt partial clone.","Verify network egress to the git host is allowed; retry with --debug if rate-limited."],"exampleFix":"# before: public URL for a private repo, no creds\n# stderr: fatal: Authentication failed for 'https://github.com/myorg/repo.git'\n\n# after: use SSH or supply a token\ngit config --global url.\"git@github.com:\".insteadOf \"https://github.com/\nrm -rf $HUGO_CACHEDIR/repo_*","handlingStrategy":"try-catch","validationCode":"// Probe the origin URL before the build to catch auth/network issues early.\nif out, err := exec.Command(\"git\",\"ls-remote\",originURL).CombinedOutput(); err != nil {\n    return fmt.Errorf(\"origin unreachable: %s: %w\", out, err)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if isAuthErr(stderr.String()) { configureCreds(); /* retry */ }\n    if isTransient(stderr.String()) { time.Sleep(backoff); /* retry */ }\n    return fmt.Errorf(\"git clone %s: %w: %s\", origin.URL, err, stderr.String())\n}","preventionTips":["Configure git credentials/SSH keys in CI via secrets, not interactive prompts.","Keep the gitinfo cache writable and clear stale repo dirs between builds.","Whitelist the git host egress in firewalls."],"tags":["git","network","authentication","gitinfo","cache","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}