{"record":{"id":"ce9afb27eec5f6a2","repo":"run-llama/llama_index","slug":"directory-input-dir-does-not-exist","errorCode":null,"errorMessage":"Directory {input_dir} does not exist.","messagePattern":"Directory (.+?) does not exist\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/readers/file/base.py","lineNumber":295,"sourceCode":"        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\n    def is_empty_file(self, path: Path | PurePosixPath) -> bool:\n        return self.fs.isfile(str(path)) and self.fs.info(str(path)).get(\"size\", 0) == 0\n\n    def _is_directory(self, path: Path | PurePosixPath) -> bool:\n        \"\"\"","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/readers/file/base.py#L277-L313","documentation":"SimpleDirectoryReader raises this ValueError during __init__ when an input_dir is passed but self.fs.isdir(input_dir) returns False. The reader validates the directory exists (on the local filesystem or the provided fsspec filesystem) before enumerating files. It exists to fail fast on a bad path instead of silently producing an empty index.","triggerScenarios":"Constructing SimpleDirectoryReader(input_dir='./data') where './data' does not exist; passing a relative path while the process cwd differs from the assumed one; passing a path on a non-default fsspec filesystem (e.g. s3fs) where isdir() is False because the prefix/bucket is wrong or credentials lack access; passing a file path instead of a directory.","commonSituations":"Notebooks run from a different working directory; typos or trailing spaces in the path; Docker containers where the data volume was not mounted at the expected path; S3/GCS prefixes that do not end the way the user expects; paths from config files or CLI args that are wrong on a new machine.","solutions":["Verify the directory exists and is readable from the process running the code: os.path.isdir(input_dir) or ls the absolute path.","Resolve the path to an absolute path before constructing the reader: Path(input_dir).resolve().","If using a custom fs argument, check the path against that filesystem's root (e.g. 'bucket/prefix' without a leading slash for s3fs), not the local filesystem.","Ensure the directory is mounted/copied into the container or VM if running in Docker/CI."],"exampleFix":"// before\nreader = SimpleDirectoryReader(input_dir=\"./data\")\n\n// after\nfrom pathlib import Path\ndata_dir = Path(\"./data\").resolve()\nassert data_dir.is_dir(), f\"missing dir: {data_dir}\"\nreader = SimpleDirectoryReader(input_dir=data_dir)","handlingStrategy":"validation","validationCode":"from pathlib import Path\ninput_dir = \"./data\"\nassert Path(input_dir).is_dir(), f\"Directory does not exist: {input_dir}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve data directories to absolute paths at startup (Path(p).resolve()).","Fail fast on missing input paths in config loading before building readers.","In containers, assert expected volumes are mounted before constructing readers."],"tags":["filesystem","path-validation","directory-reader","initialization"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}