{"record":{"id":"ba678690e8b85d89","repo":"plandex-ai/plandex","slug":"error-checking-if-file-exists-v","errorCode":null,"errorMessage":"error checking if file exists: %v","messagePattern":"error checking if file exists: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/fs/utils.go","lineNumber":15,"sourceCode":"package fs\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc FileExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t} else if os.IsNotExist(err) {\n\t\treturn false, nil\n\t} else {\n\t\treturn false, fmt.Errorf(\"error checking if file exists: %v\", err)\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/fs/utils.go#L1-L18","documentation":"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'.","triggerScenarios":"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.","commonSituations":"Custom models config path inside a directory the user can't traverse; broken symlink cycles; read-only or failing external drives.","solutions":["Check permissions on the path's parent directories (chmod/chown to allow traversal)","Remove broken symlinks along the path","Verify the storage device/mount is healthy and remount if needed","Inspect the wrapped %v error for the exact syscall failure"],"exampleFix":"// before\nchmod 000 ~/.config-dir\nFileExists(\"~/.config-dir/models.json\")  // error\n// after\nchmod 755 ~/.config-dir\nFileExists(\"~/.config-dir/models.json\")","handlingStrategy":"fallback","validationCode":"dir := filepath.Dir(path)\nif _, err := os.Stat(dir); err != nil {\n    return fmt.Errorf(\"parent dir %s not accessible: %w\", dir, err)\n}","typeGuard":null,"tryCatchPattern":"exists, err := FileExists(path)\nif err != nil {\n    log.Warn(\"existence unknown; assuming missing\", \"path\", path, \"err\", err)\n    exists = false\n}","preventionTips":["Keep config directories traversable (o+x) by the running user","Remove broken symlinks from config paths","Treat 'existence unknown' differently from 'does not exist' in your own code","Check storage health when Stat errors cluster on one mount"],"tags":["filesystem","permissions","stat-error"],"backgroundTag":"permission-denied","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"}