plandex-ai/plandex · error

error checking if file exists: %v

Error message

error checking if file exists: %v

What it means

FileExists uses os.Stat to test for a path's existence. Existence and absence return clean booleans; any other Stat error (permission denied on a parent dir, symlink loop, I/O failure) is returned as this wrapped error so callers never mistake an I/O failure for 'file missing'.

Source

Thrown at app/cli/fs/utils.go:15

package fs

import (
	"fmt"
	"os"
)

func FileExists(path string) (bool, error) {
	_, err := os.Stat(path)
	if err == nil {
		return true, nil
	} else if os.IsNotExist(err) {
		return false, nil
	} else {
		return false, fmt.Errorf("error checking if file exists: %v", err)
	}
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check permissions on the path's parent directories (chmod/chown to allow traversal)
  2. Remove broken symlinks along the path
  3. Verify the storage device/mount is healthy and remount if needed
  4. Inspect the wrapped %v error for the exact syscall failure

Example fix

// before
chmod 000 ~/.config-dir
FileExists("~/.config-dir/models.json")  // error
// after
chmod 755 ~/.config-dir
FileExists("~/.config-dir/models.json")
Defensive patterns

Strategy: fallback

Validate before calling

dir := filepath.Dir(path)
if _, err := os.Stat(dir); err != nil {
    return fmt.Errorf("parent dir %s not accessible: %w", dir, err)
}

Try / catch

exists, err := FileExists(path)
if err != nil {
    log.Warn("existence unknown; assuming missing", "path", path, "err", err)
    exists = false
}

Prevention

When it happens

Trigger: os.Stat(path) fails with an error other than fs.ErrNotExist — EACCES on an ancestor directory, ELOOP, or underlying storage I/O errors — while checking model config files in manageCustomModels / updateModelSettings flows.

Common situations: Custom models config path inside a directory the user can't traverse; broken symlink cycles; read-only or failing external drives.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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