{"record":{"id":"530eb2908feb30de","repo":"dagger/dagger","slug":"failed-to-get-file-snapshot-for-mount-d","errorCode":null,"errorMessage":"failed to get file snapshot for mount %d","messagePattern":"failed to get file snapshot for mount (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container_exec.go","lineNumber":867,"sourceCode":"\t\t\t\tmountState.Selector = selector\n\t\t\t}\n\t\t\tref, ok := dir.Snapshot.Peek()\n\t\t\tif !ok {\n\t\t\t\treturn materialized, fmt.Errorf(\"failed to get directory snapshot for mount %d\", i)\n\t\t\t}\n\t\t\tmountState.SourceRef = ref\n\n\t\tcase ctrMount.FileSource != nil:\n\t\t\tfile, ok := ctrMount.FileSource.Peek()\n\t\t\tif !ok || file == nil {\n\t\t\t\treturn materialized, fmt.Errorf(\"mount %d has nil file source\", i)\n\t\t\t}\n\t\t\tif selector, ok := file.File.Peek(); ok {\n\t\t\t\tmountState.Selector = selector\n\t\t\t}\n\t\t\tref, ok := file.Snapshot.Peek()\n\t\t\tif !ok {\n\t\t\t\treturn materialized, fmt.Errorf(\"failed to get file snapshot for mount %d\", i)\n\t\t\t}\n\t\t\tmountState.SourceRef = ref\n\n\t\tcase ctrMount.CacheSource != nil:\n\t\t\tcacheSrc := ctrMount.CacheSource\n\t\t\tif cacheSrc.Volume.Self() == nil {\n\t\t\t\treturn materialized, fmt.Errorf(\"mount %d has nil cache volume source\", i)\n\t\t\t}\n\t\t\tif cacheSrc.Volume.Self().getSnapshot() == nil {\n\t\t\t\tif err := cacheSrc.Volume.Self().InitializeSnapshot(ctx); err != nil {\n\t\t\t\t\treturn materialized, fmt.Errorf(\"initialize cache volume snapshot for mount %d: %w\", i, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcacheSnapshot := cacheSrc.Volume.Self().getSnapshot()\n\t\t\tif cacheSnapshot == nil {\n\t\t\t\treturn materialized, fmt.Errorf(\"mount %d has nil cache volume snapshot\", i)\n\t\t\t}\n\t\t\tmountState.SourceRef = cacheSnapshot","sourceCodeStart":849,"sourceCodeEnd":885,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/container_exec.go#L849-L885","documentation":"The File handle for the mount exists but its Snapshot lazy field failed to resolve, so no content-addressed reference is available to bind-mount. Equivalent to the directory snapshot failure but on the file path.","triggerScenarios":"WithMountedFile where the File's snapshot evaluation failed (upstream solve error, context cancellation, cache eviction) and is only detected when the exec runs.","commonSituations":"Transient engine/cache failures; timeouts while exporting file blobs; using a File from a different engine instance; pruned blobs behind a long-lived handle.","solutions":["Diagnose the underlying snapshot failure by evaluating the File standalone (e.g. .Contents())","Retry the producing step; transient cache/blob errors are often resolved by re-solve","Force evaluation with .Sync()/contents read before mounting to fail fast with a clearer error","Avoid carrying File handles across engine restarts or GC-pruned cache states"],"exampleFix":"// before\nctr = ctr.WithMountedFile(\"/bin/tool\", staleFile)\n// after\nif _, err := staleFile.Size(ctx); err != nil { return err }\nctr = ctr.WithMountedFile(\"/bin/tool\", staleFile)","handlingStrategy":"validation","validationCode":"if _, err := file.Size(ctx); err != nil {\n    return fmt.Errorf(\"file snapshot unavailable: %w\", err)\n}\nctr = ctr.WithMountedFile(path, file)","typeGuard":null,"tryCatchPattern":"if _, err := ctr.Sync(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to get file snapshot\") {\n        // retry after re-solving the producing step\n    }\n    return err\n}","preventionTips":["Read file contents/size beforehand to force snapshot resolution","Retry transient cache/blob failures","Do not reuse File handles across engine restarts"],"tags":["go","mount","snapshot","container-exec"],"backgroundTag":"snapshot-unavailable","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"}