{"record":{"id":"260faa178e8f13e9","repo":"plandex-ai/plandex","slug":"cannot-process-directory-s-requires-recursive","errorCode":null,"errorMessage":"cannot process directory %s: requires --recursive/-r, --tree, or --map flag","messagePattern":"cannot process directory (.+?): requires --recursive/-r, --tree, or --map flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_paths.go","lineNumber":45,"sourceCode":"\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))\n\t\t\t// if params.MaxDepth != -1 && depth > params.MaxDepth {\n\t\t\t// \treturn filepath.SkipDir\n\t\t\t// }\n\n\t\t\tif loadParams.NamesOnly {\n\t\t\t\t// add directory name to results\n\t\t\t\tresPaths = append(resPaths, path)\n\t\t\t}\n\t\t} else {\n\t\t\t// add file path to results\n\t\t\tresPaths = append(resPaths, path)\n\t\t}\n\t}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_paths.go#L27-L63","documentation":"ParseInputPaths rejects a directory argument when none of the flags that legitimize directory loading (--recursive/-r, --tree, or --map) is set. The library refuses to guess how to expand a directory into context, so it fails fast with this message naming the directory.","triggerScenarios":"Calling context load / MustLoadContext with projectPaths.AllDirs[path] true for a supplied path while loadParams.Recursive, loadParams.NamesOnly, and loadParams.DefsOnly are all false — e.g. `plandex context add src/` without -r.","commonSituations":"User passes a directory expecting it to be loaded wholesale; changed CLI defaults in a newer version; scripts that previously passed files now receive directory globs.","solutions":["Re-run with --recursive/-r to load the whole directory tree","Or use --tree / --map if a structural map of the directory is what you want","Or pass individual files instead of the directory"],"exampleFix":"// before\nplandex context add src/\n// after\nplandex context add src/ --recursive","handlingStrategy":"validation","validationCode":"info, err := os.Stat(p)\nif err == nil && info.IsDir() {\n    if !recursive && !tree && !mapFlag {\n        return fmt.Errorf(\"directory %s needs one of: -r, --tree, --map\", p)\n    }\n}","typeGuard":"func isDirectoryNeedingFlag(p string, params LoadParams, allDirs map[string]bool) bool {\n    return allDirs[p] && !(params.Recursive || params.NamesOnly || params.DefsOnly)\n}","tryCatchPattern":"paths, err := ParseInputPaths(args, baseDir, params)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"cannot process directory\") {\n        fmt.Println(\"tip: add --recursive (-r), --tree, or --map for directories\")\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Always pass -r/--tree/--map when adding directories","Wrap directory adds in scripts with the recursive flag by default","Read `context add --help` when upgrading CLI versions"],"tags":["cli","validation","directory"],"backgroundTag":"missing-required-flag","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}