{"record":{"id":"e4825df94a35a154","repo":"dagger/dagger","slug":"failed-to-get-parent-directory-path-w-e4825d","errorCode":null,"errorMessage":"failed to get parent directory path: %w","messagePattern":"failed to get parent directory path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/file.go","lineNumber":573,"sourceCode":"\t\tFilename:    lazy.Filename,\n\t\tContents:    slices.Clone(lazy.Contents),\n\t\tPermissions: lazy.Permissions,\n\t})\n}\n\nfunc (lazy *FileSubfileLazy) Evaluate(ctx context.Context, file *File) error {\n\treturn lazy.LazyState.Evaluate(ctx, \"File.file\", func(ctx context.Context) error {\n\t\tcache, err := dagql.EngineCache(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := cache.Evaluate(ctx, lazy.Parent); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tparentPath, err := lazy.Parent.Self().Dir.GetOrEval(ctx, lazy.Parent.Result)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get parent directory path: %w\", err)\n\t\t}\n\t\tfinalPath := filepath.Join(parentPath, lazy.Path)\n\n\t\tquery, err := CurrentQuery(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsrv, err := query.Server.Server(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tinfo, err := lazy.Parent.Self().Stat(ctx, lazy.Parent, srv, lazy.Path, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif info.FileType == FileTypeDirectory {\n\t\t\treturn notAFileError{fmt.Errorf(\"path %s is a directory, not a file\", lazy.Path)}","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/file.go#L555-L591","documentation":"This error wraps the underlying failure that occurred while resolving the parent directory's absolute path (`Directory.dir`) during lazy evaluation of a file sub-path. When a `File` is lazily constructed from a parent `Directory` plus a relative path (e.g. `directory.file(path)`), the engine must first evaluate the parent's path before it can stat/snapshot the file. Any error evaluating that path is re-wrapped with this message so the caller knows the failure happened in the parent-path resolution step.","triggerScenarios":"Calling `Directory.file(path)` (or `file()` on a subdirectory) where evaluating the parent directory's `Dir` field fails — e.g. the parent directory is a lazy/remote result whose path resolution errored, the parent is a scratch/ephemeral directory with no path, or an underlying cached evaluation returned an error.","commonSituations":"Building files from directories that came from remote sources (git, image layers) where the underlying evaluation failed; using a directory whose backing cache record was evicted; chained `directory(name).file(...)` calls where the intermediate directory name was invalid.","solutions":["Inspect the wrapped (`%w`) cause in the error chain — this message only indicates *where* it failed, the root cause is the inner error","Verify the parent `Directory` argument is a valid, fully-evaluable directory (e.g. `dag.currentModule().workdir` or a valid `directory(name)`), not scratch","Re-run with a fresh session/cache if a cache eviction or stale ref is suspected","If the parent directory was produced by a failed pipeline step, fix that upstream step first"],"exampleFix":"// before: parent may be scratch/invalid\ndir := client.Container().Rootfs()\nfile := dir.File(\"app/config.yaml\")\n// after: use a directory with a resolvable path\ndir := client.Host().Directory(\"./config\")\nfile := dir.File(\"app.yaml\")","handlingStrategy":"try-catch","validationCode":"// ensure parent dir is concrete before deriving files\nif dir == nil || dir.id() == \"\" { return errors.New(\"parent directory not initialized\") }","typeGuard":null,"tryCatchPattern":"try {\n  const file = dir.file(path);\n} catch (e) {\n  if (String(e).includes(\"failed to get parent directory path\")) {\n    // inspect e.cause / wrapped error for the root cause; rebuild parent dir\n  }\n  throw e;\n}","preventionTips":["Always build parent directories from concrete sources (host, git, container) before calling .file()","Check that upstream pipeline steps producing the directory succeeded","Avoid reusing directory refs across sessions or after engine restarts","Inspect the full wrapped error chain, not just the top message"],"tags":["dagger","file","directory","lazy-evaluation"],"backgroundTag":"parent-directory-path-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"}