{"record":{"id":"9bba80d4e5f97204","repo":"dagger/dagger","slug":"resolve-search-path-q-w","errorCode":null,"errorMessage":"resolve search path %q: %w","messagePattern":"resolve search path %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/client/filesync.go","lineNumber":441,"sourceCode":"\t\t// If absolute, make it relative to the root\n\t\tcleaned := p\n\t\tif filepath.IsAbs(cleaned) {\n\t\t\tcleaned = strings.TrimPrefix(cleaned, \"/\")\n\t\t}\n\n\t\t// Clean the path (e.g., remove ../, ./, etc.)\n\t\tcleaned = filepath.Clean(cleaned)\n\n\t\t// Check if the normalized path would escape the root\n\t\tif !filepath.IsLocal(cleaned) {\n\t\t\treturn nil, fmt.Errorf(\"path cannot escape search root: %s\", p)\n\t\t}\n\n\t\t// Resolve symlinks scoped to root so a symlinked path operand can't\n\t\t// point outside the root either.\n\t\tresolved, err := containerdfs.RootPath(root, cleaned)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve search path %q: %w\", p, err)\n\t\t}\n\t\trel, err := filepath.Rel(root, resolved)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve search path %q: %w\", p, err)\n\t\t}\n\t\topts.Paths[i] = rel\n\t}\n\n\trgPath, err := exec.LookPath(\"rg\")\n\tif err == nil {\n\t\treturn searchWithRipgrep(ctx, root, rgPath, opts)\n\t}\n\treturn searchWithGrep(ctx, root, opts)\n}\n\n// ripgrep JSON output types\ntype rgJSON struct {\n\tType string `json:\"type\"`","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/client/filesync.go#L423-L459","documentation":"After validating the path stays under the root, searchHostPath calls containerdfs.RootPath to resolve symlinks (scoped to the root) so a symlinked operand cannot point outside. This error wraps a failure from RootPath — typically the path does not exist under root or symlink resolution hit the filesystem error of its cause.","triggerScenarios":"A search path that passes the IsLocal check but does not exist beneath root, is a broken symlink, or crosses a symlink RootPath refuses to follow outside root; called via DiffCopy/searchHostPath.","commonSituations":"Searching for a file that was deleted or renamed on the host; typos in the path; a symlink whose target is missing or outside the root; stale cached paths after the synced directory changed.","solutions":["Verify the path exists relative to the search root on the host (ls the synced dir)","Remove or fix broken/out-of-root symlinks in the searched path","Read the wrapped RootPath cause (not-exist vs symlink loop) and address it specifically"],"exampleFix":"// before\nPaths: []string{\"link-to-missing-target\"}\n// after\nPaths: []string{\"actual-dir/file.go\"} // or fix the symlink target","handlingStrategy":"validation","validationCode":"// verify the path exists under root before searching\nabs := filepath.Join(root, rel)\nif _, err := os.Lstat(abs); err != nil {\n\t// path missing or broken symlink\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check paths exist (os.Lstat) before issuing a host search","Avoid symlinks pointing outside the synced directory, or resolve them yourself first","Keep the synced directory contents and search paths in sync (handle renames/deletes)"],"tags":["filesystem","symlink","search"],"backgroundTag":"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"}