{"record":{"id":"2ad1bbc02517ef73","repo":"plandex-ai/plandex","slug":"error-checking-if-s-is-a-subpath-of-s-s-2ad1bb","errorCode":null,"errorMessage":"error checking if %s is a subpath of %s: %s","messagePattern":"error checking if (.+?) is a subpath of (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_paths.go","lineNumber":31,"sourceCode":"\tLoadParams     *types.LoadContextParams\n}\n\nfunc ParseInputPaths(params ParseInputPathsParams) ([]string, error) {\n\tfileOrDirPaths := params.FileOrDirPaths\n\tbaseDir := params.BaseDir\n\tprojectPaths := params.ProjectPaths\n\tloadParams := params.LoadParams\n\n\tresPaths := []string{}\n\n\tfor path := range projectPaths.AllPaths {\n\t\t// see if it's a child of any of the fileOrDirPaths\n\t\tfound := false\n\t\tfor _, p := range fileOrDirPaths {\n\t\t\tvar err error\n\t\t\tfound, err = fs.IsSubpathOf(p, path, baseDir)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error checking if %s is a subpath of %s: %s\", path, p, err)\n\t\t\t}\n\t\t\tif found {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif !found {\n\t\t\tcontinue\n\t\t}\n\n\t\tif projectPaths.AllDirs[path] {\n\t\t\tif !(loadParams.Recursive || loadParams.NamesOnly || loadParams.DefsOnly) {\n\t\t\t\t// log.Println(\"path\", path, \"info.Name()\", info.Name())\n\t\t\t\treturn nil, fmt.Errorf(\"cannot process directory %s: requires --recursive/-r, --tree, or --map flag\", path)\n\t\t\t}\n\n\t\t\t// calculate directory depth from base\n\t\t\t// depth := strings.Count(path[len(p):], string(filepath.Separator))","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_paths.go#L13-L49","documentation":"ParseInputPaths checks each user-supplied path to see whether it is a subpath of one of the original fileOrDirPaths using fs.IsSubpathOf. If that filesystem/path check errors, the failure is wrapped with this message identifying both the child path and the parent candidate. It means path normalization failed before any context was loaded.","triggerScenarios":"fs.IsSubpathOf(p, path, baseDir) returns an error while iterating fileOrDirPaths — usually on invalid path strings, unreadable directories needing evaluation, or malformed relative/absolute mixes.","commonSituations":"Passing a path containing invalid characters or NUL bytes; baseDir no longer existing (deleted working directory); symlinks that cannot be resolved due to permissions.","solutions":["Check that the reported path and the parent path are both valid, existing paths","Run the command from the project root with relative paths instead of mixed absolute paths","Fix symlink/permission issues on the directories involved"],"exampleFix":"// before\nfound, err = fs.IsSubpathOf(p, path, baseDir)\nif err != nil {\n    return nil, fmt.Errorf(\"error checking if %s is a subpath of %s: %s\", path, p, err)\n}\n// after — validate inputs up front\nif _, err := os.Stat(baseDir); err != nil {\n    return nil, fmt.Errorf(\"base directory %s is not accessible: %w\", baseDir, err)\n}\nfound, err = fs.IsSubpathOf(p, path, baseDir)\nif err != nil {\n    return nil, fmt.Errorf(\"error checking if %s is a subpath of %s: %w\", path, p, err)\n}","handlingStrategy":"validation","validationCode":"func validatePaths(paths []string, baseDir string) error {\n    for _, p := range paths {\n        if !filepath.IsAbs(p) && !strings.HasPrefix(p, baseDir) {\n            p = filepath.Join(baseDir, p)\n        }\n        if _, err := os.Stat(p); err != nil {\n            return fmt.Errorf(\"path %s invalid: %w\", p, err)\n        }\n    }\n    return nil\n}","typeGuard":"func isUsablePath(p string) bool {\n    info, err := os.Stat(p)\n    return err == nil && (info.Mode().IsRegular() || info.IsDir())\n}","tryCatchPattern":"resolved, err := ParseInputPaths(raw, baseDir, params)\nif err != nil {\n    if strings.Contains(err.Error(), \"is a subpath of\") {\n        fmt.Printf(\"bad path argument: %v\\n\", err)\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Use clean relative paths from the project root","Avoid passing paths with shell-expanded globs that may not exist","Keep symlinks in the repo valid"],"tags":["filesystem","path","cli"],"backgroundTag":"invalid-path-resolution","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}