run-llama/llama_index · error · ValueError

No files found in {input_dir}.

Error message

No files found in {input_dir}.

What it means

Raised by SimpleDirectoryReader._add_files when, after walking input_dir, zero files survived the filters. Files are skipped when they are hidden (dot-prefixed parts), have a bad extension (not in required_exts or in exclude), match the exclude glob, or are empty (recursive case). The error means the directory exists but nothing in it is eligible for ingestion.

Source

Thrown at llama-index-core/llama_index/core/readers/file/base.py:425

                            rejected_dir,
                        )
                        break

            if (
                is_dir
                or skip_because_hidden
                or skip_because_bad_ext
                or skip_because_excluded
                or skip_because_empty
            ):
                continue
            else:
                all_files.add(ref)

        new_input_files = sorted(all_files)

        if len(new_input_files) == 0:
            raise ValueError(f"No files found in {input_dir}.")

        # print total number of files added
        logger.debug(
            f"> [SimpleDirectoryReader] Total files added: {len(new_input_files)}"
        )

        return new_input_files

    def _exclude_metadata(self, documents: list[Document]) -> list[Document]:
        """
        Exclude metadata from documents.

        Args:
            documents (List[Document]): List of documents.

        """
        for doc in documents:
            # Keep only metadata['file_path'] in both embedding and llm content

View on GitHub (pinned to afd0fef371)

Solutions

  1. List what would be ingested: check the directory contents and compare extensions case-sensitively against required_exts (include both '.pdf' and '.PDF' or normalize).
  2. Loosen or remove exclude/recursive filters to confirm they are not removing everything.
  3. If files are empty (0 bytes), fix the upstream export/copy step that produced them.
  4. Pass input_files=[...] explicitly if you know the exact files you want, bypassing directory filtering.

Example fix

# before
reader = SimpleDirectoryReader(input_dir="./docs", required_exts=[".PDF"])

# after
reader = SimpleDirectoryReader(
    input_dir="./docs",
    required_exts=[".pdf", ".PDF"],
)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
exts = {p.suffix.lower() for p in Path("./docs").rglob("*") if p.is_file()}
assert exts, "no files found"
assert ".pdf" in exts, f"no .pdf files; found: {exts}"

Prevention

When it happens

Trigger: Passing required_exts=['.pdf'] to a directory containing only .txt/.docx files; using exclude patterns that match everything; pointing at a directory that only contains hidden dotfiles or empty subdirectories with only empty files; a directory whose files are all 0 bytes.

Common situations: Data exported to a different format than expected; case-sensitivity mistakes such as required_exts=['.PDF'] on Linux while files are named .pdf; recursive=True against a tree where only hidden config files exist; overly broad exclude='**' patterns.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/29b9795370e718e2. Report an issue: GitHub.