dagger/dagger · error
git commit tree: missing commit
Error message
git commit tree: missing commit
What it means
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.
Source
Thrown at core/git.go:702
backend, err := repo.Self().Backend.Get(ctx, fetchRef)
if err != nil {
return nil, err
}
return &GitCommit{
Repo: repo,
Backend: backend,
Ref: ref,
FetchRef: fetchRef,
}, nil
}
func (ref *GitRef) Tree(ctx context.Context, srv *dagql.Server, discardGitDir bool, depth int, includeTags bool) (*Directory, error) {
return ref.Backend.Tree(ctx, srv, ref.Repo.Self().DiscardGitDir || discardGitDir, depth, includeTags)
}
func (commit *GitCommit) Tree(ctx context.Context, srv *dagql.Server, discardGitDir bool, depth int, includeTags bool) (*Directory, error) {
if commit == nil || commit.Ref == nil {
return nil, fmt.Errorf("git commit tree: missing commit")
}
if err := commit.prefetch(ctx, depth, includeTags); err != nil {
return nil, err
}
backend, err := commit.Repo.Self().Backend.Get(ctx, commit.Ref)
if err != nil {
return nil, err
}
return backend.Tree(ctx, srv, commit.Repo.Self().DiscardGitDir || discardGitDir, depth, includeTags)
}
func (commit *GitCommit) Metadata(ctx context.Context) (*GitCommitMetadata, error) {
if commit == nil || commit.Ref == nil {
return nil, fmt.Errorf("git commit metadata: missing commit")
}
if commit.Ref.SHA == "" {
return nil, fmt.Errorf("git commit metadata: missing commit SHA")
}View on GitHub (pinned to 82ba2681db)
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
Example fix
// before
commit, _ := repo.Commit(ctx, sha) // error ignored
dir, err := commit.Tree(ctx, srv, false, 0, false) // missing commit
// after
commit, err := repo.Commit(ctx, sha)
if err != nil { return err }
if commit == nil || commit.Ref == nil { return fmt.Errorf("commit %s not resolved", sha) }
dir, err := commit.Tree(ctx, srv, false, 0, false) Defensive patterns
Strategy: validation
Validate before calling
if commit == nil || commit.Ref == nil {
return fmt.Errorf("cannot fetch tree: commit not resolved")
} Type guard
func treeableCommit(c *GitCommit) bool { return c != nil && c.Ref != nil } Try / catch
dir, err := commit.Tree(ctx, srv, discardGitDir, depth, includeTags)
if err != nil {
return fmt.Errorf("git commit tree: %w", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: GraphQL resolvers forwarding nil commits after upstream errors were dropped; custom tooling building GitCommit values by hand; version regressions in commit resolution.
Related errors
- select latest git ref: nil remote
- encode persisted git ref: nil ref
- encode persisted git ref: missing ref
- encode persisted git commit: nil commit
- encode persisted git commit: missing ref
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/b016f0ec747747f4.
Report an issue: GitHub.