{"record":{"id":"7da0a2e494db20b6","repo":"dagger/dagger","slug":"failed-to-load-git-dir-w","errorCode":null,"errorMessage":"failed to load git dir: %w","messagePattern":"failed to load git dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/modulesource.go","lineNumber":790,"sourceCode":"\t\tConfigFilename: modules.Filename,\n\t\tKind:           core.ModuleSourceKindGit,\n\t\tGit: &core.GitModuleSource{\n\t\t\tHTMLRepoURL:  parsed.RepoRoot.Repo,\n\t\t\tRepoRootPath: parsed.RepoRoot.Root,\n\t\t\tVersion:      cmp.Or(gitRef.Self().Ref.ShortName(), gitRef.Self().Ref.SHA),\n\t\t\tCommit:       gitRef.Self().Ref.SHA,\n\t\t\tRef:          gitRef.Self().Ref.Name,\n\t\t\tCloneRef:     parsed.SourceCloneRef,\n\t\t},\n\t}\n\n\t// TODO:(sipsma) support sparse loading of git repos similar to how local dirs are loaded.\n\t// Related: https://github.com/dagger/dagger/issues/6292\n\terr = dag.Select(ctx, gitRef, &gitSrc.ContextDirectory,\n\t\tdagql.Selector{Field: \"tree\"},\n\t)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to load git dir: %w\", err)\n\t}\n\tgitSrc.Git.UnfilteredContextDir = gitSrc.ContextDirectory\n\n\tgitSrc.SourceRootSubpath = strings.TrimPrefix(parsed.RepoRootSubdir, \"/\")\n\tgitSrc.OriginalSubpath = gitSrc.SourceRootSubpath\n\n\t_, configFound, err := s.findGitModuleConfig(ctx, gitSrc, doFindUp, allowNotExists)\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\tif gitSrc.SourceRootSubpath == \"\" {\n\t\tgitSrc.SourceRootSubpath = \".\"\n\t}\n\n\tgitSrc.Git.Symbolic = gitSrc.Git.CloneRef\n\tif gitSrc.SourceRootSubpath != \".\" {\n\t\tgitSrc.Git.Symbolic += \"/\" + gitSrc.SourceRootSubpath\n\t}","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/modulesource.go#L772-L808","documentation":"gitModuleSource selects the `tree` field on the resolved gitRef to materialize the repository contents into a Directory (gitSrc.ContextDirectory). If that dagql selection fails, the error is wrapped as 'failed to load git dir'. The git ref resolved, but its file tree could not be produced.","triggerScenarios":"dag.Select(ctx, gitRef, &gitSrc.ContextDirectory, Selector{Field: \"tree\"}) fails — e.g. failure fetching objects for the ref, shallow/partial clone issues, or engine error building the tree Directory for a large/unusual repo.","commonSituations":"Very large repos hitting fetch/size limits; flaky network mid-fetch; git host rate-limiting the engine; pinned commit not fully available on the fetched remote.","solutions":["Retry — transient fetch failures are common","Verify the ref is fetchable: git clone at the same commit in your environment","Check for git host rate limits or proxy interference","Reduce scope (narrow subpath/ref) or use a local module source if repo size is the issue"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Force the tree to materialize before module load\nawait client.git(repoUrl).ref(ref).tree().id();","typeGuard":null,"tryCatchPattern":"try {\n  const mod = await client.moduleSource(gitRef).load();\n} catch (e) {\n  if (String(e).includes(\"failed to load git dir\")) {\n    // retry; check network/rate limits if persistent\n  }\n  throw e;\n}","preventionTips":["Retry transient tree-load failures with backoff","Watch git host rate limits; avoid excessive fetches","For very large repos consider a local checkout or narrower source","Ensure the pinned commit is fully available on the remote"],"tags":["git","directory","dagql"],"backgroundTag":"git-ref-resolution-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}