{"record":{"id":"adb88a54423549fa","repo":"run-llama/llama_index","slug":"must-provide-either-input-dir-or-input-files","errorCode":null,"errorMessage":"Must provide either `input_dir` or `input_files`.","messagePattern":"Must provide either `input_dir` or `input_files`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/readers/file/base.py","lineNumber":271,"sourceCode":"        exclude: Optional[list] = None,\n        exclude_hidden: bool = True,\n        exclude_empty: bool = False,\n        errors: str = \"ignore\",\n        recursive: bool = False,\n        encoding: str = \"utf-8\",\n        filename_as_id: bool = False,\n        required_exts: Optional[list[str]] = None,\n        file_extractor: Optional[dict[str, BaseReader]] = None,\n        num_files_limit: Optional[int] = None,\n        file_metadata: Optional[Callable[[str], dict]] = None,\n        raise_on_error: bool = False,\n        fs: fsspec.AbstractFileSystem | None = None,\n    ) -> None:\n        \"\"\"Initialize with parameters.\"\"\"\n        super().__init__()\n\n        if not input_dir and not input_files:\n            raise ValueError(\"Must provide either `input_dir` or `input_files`.\")\n\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):","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/readers/file/base.py#L253-L289","documentation":"SimpleDirectoryReader requires exactly one input source: a directory (input_dir) or an explicit file list (input_files). The constructor raises ValueError('Must provide either `input_dir` or `input_files`.') when both are falsy, so an instance never exists without a source.","triggerScenarios":"SimpleDirectoryReader() with no arguments, or with input_dir=None/input_files=[] when forwarding optional config (CLI flags, env vars, parsed YAML) that resolved to nothing.","commonSituations":"Config plumbing where a missing CLI arg becomes None and is passed through; typos like input_dirr=... leave both real parameters unset.","solutions":["Pass input_dir=\"./data\" or input_files=[\"a.pdf\", \"b.txt\"]","Validate upstream config before constructing: raise a clear config error when neither is set","Check for typos/renames in the keyword arguments you pass"],"exampleFix":"// before\ninput_dir = args.dir  # None when flag omitted\nreader = SimpleDirectoryReader(input_dir=input_dir, input_files=args.files)  # both empty -> raises\n\n// after\nif not args.dir and not args.files:\n    raise SystemExit(\"Provide --dir or --files\")\nreader = SimpleDirectoryReader(\n    input_dir=args.dir,\n    input_files=args.files or None,\n)","handlingStrategy":"validation","validationCode":"def make_reader(input_dir=None, input_files=None, **kw):\n    if not input_dir and not input_files:\n        raise ValueError(\"Reader config error: set input_dir or input_files\")\n    return SimpleDirectoryReader(\n        input_dir=input_dir or None,\n        input_files=input_files or None,\n        **kw,\n    )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate config at startup before building readers","Beware kwargs typos — a misspelled input_dir leaves the real parameter unset","Treat empty input_files the same as unset when plumbing optional CLI/env values"],"tags":["reader","filesystem","config","constructor"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}