#2576·graphrag

[Bug]: FileStorage.find returns matching directories as file keys

Author: LinxiushenCreated Sep 27, 2026Updated Sep 28, 2026

Describe the bug

FileStorage.find() yields directories when their paths match file_pattern, although its contract is to find files. A directory named archive.txt is returned by the usual text-file pattern; passing that returned key to get() raises PermissionError on Windows. Broad patterns such as .* also return ordinary directories.

The input reader catches read errors and skips these entries, so this does not necessarily abort indexing. It does cause unnecessary failed reads/warnings and inflated file counts, and direct storage consumers receive keys that are not readable files.

Steps to reproduce

Run from an environment with the current graphrag-storage package:

python
import asyncio
import re
from pathlib import Path
from tempfile import TemporaryDirectory

from graphrag_storage.file_storage import FileStorage


async def main():
    with TemporaryDirectory() as directory:
        archive = Path(directory) / "archive.txt"
        archive.mkdir()
        (archive / "document.txt").write_text("real document", encoding="utf-8")
        storage = FileStorage(directory)
        keys = list(storage.find(re.compile(r".*\.txt$")))
        print(keys)
        for key in keys:
            print(key, await storage.get(key))


asyncio.run(main())

On Windows the keys are ['archive.txt', 'archive.txt\\document.txt'], and the first read raises PermissionError: [Errno 13] Permission denied for the directory. Reading the nested document directly succeeds.

Expected behavior

Return only the matching file archive.txt/document.txt (using the platform's path separator), retaining recursive discovery of files inside matching directories. Empty directories should not be returned either.

Configuration and environment

  • GraphRAG storage 3.2.0, upstream commit 769542fbf1d8e5b4c6a8677fefc34621c87894c5.
  • Windows, Python 3.12.13; repository-locked storage dependencies installed with uv sync --frozen --package graphrag-storage --no-dev --python 3.12.
  • No model hosting, credentials, inference, or settings.yaml is involved; this is a local storage API issue.
  • Searched open and closed issues/PRs for FileStorage, directories, file patterns, and is_file; no matching fix found.

I can contribute a focused fix and real-filesystem regression coverage.