{"record":{"id":"eaf8805622d1f94d","repo":"run-llama/llama_index","slug":"file-path-does-not-exist","errorCode":null,"errorMessage":"File {path} does not exist.","messagePattern":"File (.+?) does not exist\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/readers/file/base.py","lineNumber":290,"sourceCode":"\n        self.fs = fs or get_default_fs()\n        self.errors = errors\n        self.encoding = encoding\n\n        self.exclude = exclude\n        self.recursive = recursive\n        self.exclude_hidden = exclude_hidden\n        self.exclude_empty = exclude_empty\n        self.required_exts = required_exts\n        self.num_files_limit = num_files_limit\n        self.raise_on_error = raise_on_error\n        _Path = Path if is_default_fs(self.fs) else PurePosixPath\n\n        if input_files:\n            self.input_files = []\n            for path in input_files:\n                if not self.fs.isfile(path):\n                    raise ValueError(f\"File {path} does not exist.\")\n                input_file = _Path(path)\n                self.input_files.append(input_file)\n        elif input_dir:\n            if not self.fs.isdir(input_dir):\n                raise ValueError(f\"Directory {input_dir} does not exist.\")\n            self.input_dir = _Path(input_dir)\n            self.exclude = exclude\n            self.input_files = self._add_files(self.input_dir)\n\n        self.file_extractor = file_extractor or {}\n        self.file_metadata = file_metadata or _DefaultFileMetadataFunc(self.fs)\n        self.filename_as_id = filename_as_id\n\n    def is_hidden(self, path: Path | PurePosixPath) -> bool:\n        return any(\n            part.startswith(\".\") and part not in [\".\", \"..\"] for part in path.parts\n        )\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/readers/file/base.py#L272-L308","documentation":"During SimpleDirectoryReader construction, each path in input_files is checked with fs.isfile(path); a path that is not an existing file raises ValueError('File {path} does not exist.'). This is eager validation so failures surface before any loading starts.","triggerScenarios":"Passing input_files=[\"data/report.pdf\"] where the file was moved/deleted, the relative path is resolved from a different working directory, or a remote fsspec filesystem (fs=...) is given local-style paths.","commonSituations":"Relative paths breaking when the process cwd differs (cron jobs, notebooks run from another directory), stale file lists, or using a custom fs while passing paths valid only on local disk.","solutions":["Check paths before constructing: [p for p in files if Path(p).is_file()] or pre-resolve with Path(...).resolve()","Use absolute paths (e.g. build them from a project-root anchor) instead of cwd-relative ones","When using a custom fsspec fs, pass paths as that filesystem expects (scheme/keys), since fs.isfile is what validates"],"exampleFix":"// before\nreader = SimpleDirectoryReader(input_files=[\"data/report.pdf\"])  # cwd mismatch -> raises\n\n// after\nfrom pathlib import Path\nroot = Path(__file__).parent\nfiles = [str(p) for p in (root / \"data\").glob(\"*.pdf\") if p.is_file()]\nreader = SimpleDirectoryReader(input_files=files)","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nfiles = [Path(p) for p in input_files]\nmissing = [p for p in files if not p.is_file()]\nif missing:\n    raise FileNotFoundError(f\"missing input files: {missing}\")\nreader = SimpleDirectoryReader(input_files=[str(p) for p in files])","typeGuard":null,"tryCatchPattern":"try:\n    reader = SimpleDirectoryReader(input_files=files)\nexcept ValueError as e:\n    if \"does not exist\" in str(e):\n        files = [f for f in files if Path(f).is_file()]\n        if not files:\n            raise\n        reader = SimpleDirectoryReader(input_files=files)\n    else:\n        raise","preventionTips":["Resolve paths to absolute form at process start (anchor to project root or __file__)","Filter/validate file lists before constructing the reader","Remember the check runs in the constructor — failures are eager, so catch them at setup, not per-query"],"tags":["filesystem","paths","validation","reader"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}