plandex-ai/plandex · error

failed to get directory tree %s: %v

Error message

failed to get directory tree %s: %v

What it means

Produced when ParseInputPaths fails while recomputing a directory-tree context. The library walks the tree directory to enumerate files (names-only mode) and wraps any walk/parse failure with the tree's root path. The tree root still exists (the prior IsNotExist check passed), so the failure is inside path parsing, ignore-rule handling, or permission on subdirectories.

Source

Thrown at app/cli/lib/context_update.go:508

					return
				}

				baseDir := fs.GetBaseDirForFilePaths([]string{ctx.FilePath})
				flattenedPaths, err := ParseInputPaths(ParseInputPathsParams{
					FileOrDirPaths: []string{ctx.FilePath},
					BaseDir:        baseDir,
					ProjectPaths:   paths,
					LoadParams: &types.LoadContextParams{
						NamesOnly:       true,
						ForceSkipIgnore: ctx.ForceSkipIgnore,
					},
				})

				if err != nil {
					mu.Lock()
					defer mu.Unlock()

					errs = append(errs, fmt.Errorf("failed to get directory tree %s: %v", ctx.FilePath, err))
					return
				}

				if !ctx.ForceSkipIgnore && paths != nil {
					var filtered []string
					for _, p := range flattenedPaths {
						if _, ok := paths.ActivePaths[p]; ok {
							filtered = append(filtered, p)
						}
					}
					flattenedPaths = filtered
				}

				// Partial skipping for sub-paths
				var kept []string
				mu.Lock()
				for _, p := range flattenedPaths {
					lineSize := int64(len(p))

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the wrapped %v error; restore read/execute permissions on the offending subdirectory.
  2. Fix or remove malformed ignore patterns (.gitignore or project ignore config) under the tree root.
  3. Remove broken symlinks or symlink loops inside the tree.
  4. If the tree root is stale, remove and re-add the directory-tree context.

Example fix

// before
drwx------ private/   # inside tree root, walk fails
// after
chmod o+rx private/    # or exclude it via ignore rules
Defensive patterns

Strategy: validation

Validate before calling

err := filepath.WalkDir(treeRoot, func(p string, d fs.DirEntry, err error) error {
    if err != nil { return fmt.Errorf("unreadable under %s: %w", p, err) }
    return nil
})
if err != nil { return err } // fix perms/symlinks before refreshing the tree context

Try / catch

if err := refreshTreeCtx(ctx); err != nil {
    if strings.Contains(err.Error(), "failed to get directory tree") {
        // inspect wrapped cause: perms, ignore rules, symlinks
    }
}

Prevention

When it happens

Trigger: ParseInputPathsParams{NamesOnly:true, ForceSkipIgnore:...} returns err for ctx.FilePath during the directory-tree goroutine — e.g. unreadable subdirectory, symlink loop, or invalid ignore patterns under the tree.

Common situations: A subdirectory of the tree was made inaccessible (chmod 000) or deleted mid-walk; malformed .gitignore/ignore rules; symlink cycles causing walk errors; project paths config referencing invalid globs.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/5a53c9bb4674f030. Report an issue: GitHub.