{"record":{"id":"b016f0ec747747f4","repo":"dagger/dagger","slug":"git-commit-tree-missing-commit","errorCode":null,"errorMessage":"git commit tree: missing commit","messagePattern":"git commit tree: missing commit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/git.go","lineNumber":702,"sourceCode":"\tbackend, err := repo.Self().Backend.Get(ctx, fetchRef)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &GitCommit{\n\t\tRepo:     repo,\n\t\tBackend:  backend,\n\t\tRef:      ref,\n\t\tFetchRef: fetchRef,\n\t}, nil\n}\n\nfunc (ref *GitRef) Tree(ctx context.Context, srv *dagql.Server, discardGitDir bool, depth int, includeTags bool) (*Directory, error) {\n\treturn ref.Backend.Tree(ctx, srv, ref.Repo.Self().DiscardGitDir || discardGitDir, depth, includeTags)\n}\n\nfunc (commit *GitCommit) Tree(ctx context.Context, srv *dagql.Server, discardGitDir bool, depth int, includeTags bool) (*Directory, error) {\n\tif commit == nil || commit.Ref == nil {\n\t\treturn nil, fmt.Errorf(\"git commit tree: missing commit\")\n\t}\n\tif err := commit.prefetch(ctx, depth, includeTags); err != nil {\n\t\treturn nil, err\n\t}\n\tbackend, err := commit.Repo.Self().Backend.Get(ctx, commit.Ref)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn backend.Tree(ctx, srv, commit.Repo.Self().DiscardGitDir || discardGitDir, depth, includeTags)\n}\n\nfunc (commit *GitCommit) Metadata(ctx context.Context) (*GitCommitMetadata, error) {\n\tif commit == nil || commit.Ref == nil {\n\t\treturn nil, fmt.Errorf(\"git commit metadata: missing commit\")\n\t}\n\tif commit.Ref.SHA == \"\" {\n\t\treturn nil, fmt.Errorf(\"git commit metadata: missing commit SHA\")\n\t}","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/git.go#L684-L720","documentation":"GitCommit.Tree returns this error when the receiver is nil or its Ref is nil, meaning there is no actual commit to fetch a tree for. It is a defensive guard before prefetching and resolving the commit's directory tree in the repo backend.","triggerScenarios":"Calling Tree on a *GitCommit obtained from a path that returned nil or left Ref unset — e.g. a failed/short-circuited commit resolution whose nil result was passed along, or manual struct assembly without a Ref.","commonSituations":"GraphQL resolvers forwarding nil commits after upstream errors were dropped; custom tooling building GitCommit values by hand; version regressions in commit resolution.","solutions":["Check the code that produced the GitCommit: ensure errors from commit resolution are propagated instead of returning nil objects","Only call Tree on commits obtained via repo.Branch(...).Commit(...) / repo.Commit(...) dagql APIs","Add a caller-side nil/Ref check before invoking Tree","If it surfaces from normal dagger usage, capture the full trace and file an upstream issue — resolvers should never hand nil commits to Tree"],"exampleFix":"// before\ncommit, _ := repo.Commit(ctx, sha) // error ignored\ndir, err := commit.Tree(ctx, srv, false, 0, false) // missing commit\n// after\ncommit, err := repo.Commit(ctx, sha)\nif err != nil { return err }\nif commit == nil || commit.Ref == nil { return fmt.Errorf(\"commit %s not resolved\", sha) }\ndir, err := commit.Tree(ctx, srv, false, 0, false)","handlingStrategy":"validation","validationCode":"if commit == nil || commit.Ref == nil {\n\treturn fmt.Errorf(\"cannot fetch tree: commit not resolved\")\n}","typeGuard":"func treeableCommit(c *GitCommit) bool { return c != nil && c.Ref != nil }","tryCatchPattern":"dir, err := commit.Tree(ctx, srv, discardGitDir, depth, includeTags)\nif err != nil {\n\treturn fmt.Errorf(\"git commit tree: %w\", err)\n}","preventionTips":["Propagate errors from commit resolution instead of passing nil results onward","Use dagql git APIs to obtain commits","Check commit/Ref before tree operations in custom tooling"],"tags":["git","nil-pointer","tree","missing-object"],"backgroundTag":"nil-object-serialization","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"}