{"record":{"id":"d6b4c659deeaf855","repo":"dagger/dagger","slug":"get-canonical-checkout-snapshot-w","errorCode":null,"errorMessage":"get canonical checkout snapshot: %w","messagePattern":"get canonical checkout snapshot: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/git_hostdir.go","lineNumber":219,"sourceCode":"\tdir.Dir.setValue(\"/.git\")\n\tdir.Snapshot.setValue(snap)\n\treturn dir, nil\n}\n\n// MaterializeGitUncommittedPack applies a client-produced binary patch of\n// uncommitted changes (tracked modifications plus untracked files) to a\n// canonical HEAD checkout and recreates lightweight markers for omitted\n// untracked nested repositories. The result keeps HEAD's canonical .git and a\n// dirty working tree suitable for LocalGitRepository.uncommitted.\nfunc MaterializeGitUncommittedPack(ctx context.Context, tree dagql.ObjectResult[*Directory], pack *engineutil.GitUncommittedPack) (inst dagql.ObjectResult[*Directory], rerr error) {\n\tsrv := dagql.CurrentDagqlServer(ctx)\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\tparent, err := tree.Self().Snapshot.GetOrEval(ctx, tree.Result)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"get canonical checkout snapshot: %w\", err)\n\t}\n\ttreePath, err := tree.Self().Dir.GetOrEval(ctx, tree.Result)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"get canonical checkout path: %w\", err)\n\t}\n\n\tbkref, err := query.SnapshotManager().New(ctx, parent,\n\t\tbkcache.WithRecordType(bkclient.UsageRecordTypeRegular),\n\t\tbkcache.WithDescription(\"git uncommitted changes\"))\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\tdefer func() {\n\t\tif rerr != nil && bkref != nil {\n\t\t\tbkref.Release(context.WithoutCancel(ctx))\n\t\t}\n\t}()\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/git_hostdir.go#L201-L237","documentation":"This error wraps any failure that occurs while evaluating the canonical checkout snapshot (the underlying cache ref) of the Directory passed to MaterializeGitUncommittedPack. Dagger needs the parent snapshot before it can create a new cache ref to apply uncommitted changes on top of; if resolving/evaluating that snapshot fails, the error is wrapped with this message. It indicates the source Directory tree could not be materialized, often due to an upstream error in the tree's evaluation chain.","triggerScenarios":"Calling MaterializeGitUncommittedPack (via withGitUncommitted, e.g. host.directory(...).terminal or any uncommitted host directory load) when tree.Self().Snapshot.GetOrEval fails — the source directory snapshot cannot be resolved from the cache.","commonSituations":"The host directory was captured but its underlying git checkout snapshot was evicted or failed to build; context canceled mid-evaluation; an earlier pipeline stage errored leaving the LazyAccessor with an error result; cache/ref corruption after an engine crash.","solutions":["Inspect the wrapped (%w) cause in the error chain — it names the real failure in the snapshot evaluation","Re-run the command; transient mount/cache evaluation failures often resolve on retry","Restart the Dagger engine to clear corrupted cache state (dagger engine restart / prune cache)","Verify the source directory tree is valid and its own dependencies (services, git ref) resolve correctly before calling"],"exampleFix":"// before: no context on failure path\nparent, err := tree.Self().Snapshot.GetOrEval(ctx, tree.Result)\nif err != nil {\n    return inst, err\n}\n// after: wrap with actionable message\nparent, err := tree.Self().Snapshot.GetOrEval(ctx, tree.Result)\nif err != nil {\n    return inst, fmt.Errorf(\"get canonical checkout snapshot: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// ensure source dir resolves before materializing\nif _, err := tree.Self().Snapshot.GetOrEval(ctx, tree.Result); err != nil {\n    return fmt.Errorf(\"source snapshot unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"inst, err := MaterializeGitUncommittedPack(ctx, tree, pack)\nif err != nil {\n    if strings.Contains(err.Error(), \"get canonical checkout snapshot\") {\n        // inspect wrapped cause; retry or restart engine\n    }\n    return err\n}","preventionTips":["Always inspect the wrapped cause with errors.Unwrap / %w chain","Keep engine cache healthy; avoid pruning concurrently with runs","Retry transient snapshot evaluation failures","Load host directories fresh rather than reusing long-lived results"],"tags":["git","cache","snapshot","host-directory"],"backgroundTag":"git-snapshot-eval-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}