{"record":{"id":"fc1bfca9765b93af","repo":"dagger/dagger","slug":"failed-to-get-ref-for-source-directory-w","errorCode":null,"errorMessage":"failed to get ref for source directory: %w","messagePattern":"failed to get ref for source directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/service.go","lineNumber":1465,"sourceCode":"\trunning.workspaceMu.Lock()\n\tdefer running.workspaceMu.Unlock()\n\n\tcache, err := dagql.EngineCache(ctx)\n\tif err != nil {\n\t\treturn res, false, err\n\t}\n\tif err := cache.Evaluate(ctx, source); err != nil {\n\t\treturn res, false, fmt.Errorf(\"failed to evaluate source directory: %w\", err)\n\t}\n\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn res, false, err\n\t}\n\n\tref, err := source.Self().Snapshot.GetOrEval(ctx, source.Result)\n\tif err != nil {\n\t\treturn res, false, fmt.Errorf(\"failed to get ref for source directory: %w\", err)\n\t}\n\tsourceDirPath, err := source.Self().Dir.GetOrEval(ctx, source.Result)\n\tif err != nil {\n\t\treturn res, false, fmt.Errorf(\"failed to get path for source directory: %w\", err)\n\t}\n\n\tbk, err := query.Engine(ctx)\n\tif err != nil {\n\t\treturn res, false, fmt.Errorf(\"failed to get engine client: %w\", err)\n\t}\n\n\tmutableRef, err := query.SnapshotManager().New(ctx, ref,\n\t\tbkcache.WithRecordType(bkclient.UsageRecordTypeRegular),\n\t\tbkcache.WithDescription(\"mcp remount\"))\n\tif err != nil {\n\t\treturn res, false, fmt.Errorf(\"failed to create new ref for source directory: %w\", err)\n\t}\n\tdefer func() {","sourceCodeStart":1447,"sourceCodeEnd":1483,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/service.go#L1447-L1483","documentation":"Error 'failed to get ref for source directory: %w' (core/service.go:1465) wraps errors from source.Self().Snapshot.GetOrEval in runAndSnapshotChanges. Snapshot.GetOrEval resolves the directory to an underlying ImmutableRef (a content-addressed snapshot); failure means the directory's contents could not be resolved to a stored layer/ref in the engine.","triggerScenarios":"Calling runAndSnapshotChanges where source.Self().Snapshot.GetOrEval fails — e.g. the directory ref points to data not present in the content store (garbage-collected), the snapshot backend errors, or evaluation of the underlying result fails.","commonSituations":"Content-store eviction or corrupted cache on the engine; a directory produced by a remote source that failed to import; running against a containerd/buildkit store with permission problems.","solutions":["Read the wrapped %w error to identify the snapshot/ref failure","Prune and retry: clean a corrupted engine cache (dagger engine prune / restart engine)","Re-create the Directory from its source so the snapshot is regenerated","Check content-store permissions/disk space on the engine host"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: retry once on snapshot resolution failure (possible transient cache issue)\nres, _, err := runAndSnapshotChanges(ctx, running, target, src, fn)\nif err != nil && strings.Contains(err.Error(), \"failed to get ref for source directory\") {\n    return runAndSnapshotChanges(ctx, running, target, rebuildSrc(ctx), fn)\n}","preventionTips":["Keep sufficient disk space for the engine content store","Prune/restart the engine if the cache becomes corrupted","Re-create directories from source instead of reusing stale refs"],"tags":["go","dagger","snapshot","directory","content-store"],"backgroundTag":"snapshot-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"}