{"record":{"id":"6e9095e35e48c438","repo":"GoogleContainerTools/skaffold","slug":"failed-to-clone-git-repo-unable-to-create-directo","errorCode":null,"errorMessage":"failed to clone git repo: unable to create directory name: %w","messagePattern":"failed to clone git repo: unable to create directory name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/git/gitutil.go","lineNumber":120,"sourceCode":"\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: %w\", g.Repo, err)\n\t}\n\tif err := os.MkdirAll(skaffoldCacheDir, 0700); err != nil {\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"failed to clone repo %s: trouble creating cache directory: %w\", g.Repo, err)\n\t}\n\n\tref := g.Ref\n\tif ref == \"\" {\n\t\tref, err = defaultRef(ctx, g.RepoCloneURI, g.Repo)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: trouble getting default branch: %w\", g.Repo, err)\n\t\t}\n\t}\n\n\thash, err := getRepoDir(g)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to clone git repo: unable to create directory name: %w\", err)\n\t}\n\trepoCacheDir := filepath.Join(skaffoldCacheDir, hash)\n\tif _, err := os.Stat(repoCacheDir); os.IsNotExist(err) {\n\t\tif opts.SyncRemoteCache.CloneDisabled() {\n\t\t\treturn \"\", SyncDisabledErr(g, repoCacheDir)\n\t\t}\n\t\tif _, err := r.Run(ctx, \"clone\", g.RepoCloneURI, fmt.Sprintf(\"./%s\", hash), \"--branch\", ref, \"--depth\", \"1\"); err != nil {\n\t\t\tif strings.Contains(err.Error(), \"Could not find remote branch\") {\n\t\t\t\tif _, err := r.Run(ctx, \"clone\", g.RepoCloneURI, fmt.Sprintf(\"./%s\", hash), \"--depth\", \"1\"); err != nil {\n\t\t\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo: %w\", err)\n\t\t\t\t}\n\n\t\t\t\tr.Dir = repoCacheDir\n\t\t\t\tif _, err := r.Run(ctx, \"checkout\", ref); err != nil {\n\t\t\t\t\tif rmErr := os.RemoveAll(repoCacheDir); rmErr != nil {\n\t\t\t\t\t\terr = fmt.Errorf(\"failed to remove repo cache dir: %w\", rmErr)\n\t\t\t\t\t}\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/git/gitutil.go#L102-L138","documentation":"Thrown by syncRepo when getRepoDir(g) fails to compute the hashed cache directory name for the repo. getRepoDir hashes the repo URL/ref into a directory name, so failure indicates an internal hashing or configuration problem rather than a git issue. This is rare and usually points at malformed GitInfo input.","triggerScenarios":"getRepoDir(g) returns an error while computing the hash for the given GitInfo (unexpected repo/ref values fed to the hashing routine).","commonSituations":"Programmatic use of the skaffold git package with a malformed or empty GitInfo; unusual characters in the repo URL breaking the path derivation; upstream bug in getRepoDir's hashing of a specific repo/ref combination.","solutions":["Inspect the git sync config values (repo URL, ref, subDir) for typos, empty strings, or unexpected characters and correct them.","Reproduce with a canonical repo URL to confirm whether the URL format is the problem.","If inputs look valid, file/report a skaffold bug with the exact GitInfo values; this path is normally unreachable with well-formed config.","Pin/upgrade to a skaffold version where getRepoDir handles your input correctly."],"exampleFix":"// before\ngit.Sync{Repo: \"\", Ref: \"\"}          // malformed GitInfo\n// after\ngit.Sync{Repo: \"https://github.com/org/repo\", Ref: \"main\"}","handlingStrategy":"validation","validationCode":"function validateGitInfo(g) {\n  const errs = [];\n  if (!g || typeof g.repo !== 'string' || g.repo.length === 0) errs.push('repo required');\n  if (g.ref != null && typeof g.ref !== 'string') errs.push('ref must be string');\n  if (errs.length) throw new Error('invalid git config: ' + errs.join('; '));\n}","typeGuard":"function isValidGitInfo(g) {\n  return !!g && typeof g.repo === 'string' && g.repo.trim().length > 0 &&\n         (g.ref === undefined || typeof g.ref === 'string');\n}","tryCatchPattern":"try {\n  await syncRepo(g, ctx, opts);\n} catch (err) {\n  if (/unable to create directory name/.test(err.message)) {\n    // log full GitInfo for bug report; not user-fixable at runtime\n    console.error('getRepoDir failed for GitInfo:', JSON.stringify(g));\n  }\n  throw err;\n}","preventionTips":["Only pass well-formed repo URLs (https:// or git@host:path) into git sync config.","Avoid exotic characters/control chars in repo and ref fields.","Pin skaffold versions tested against your repo naming scheme.","Validate config with skaffold config linting before runs."],"tags":["git","configuration","hashing"],"backgroundTag":"invalid-git-config","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}