{"record":{"id":"0196581080ea4220","repo":"run-llama/llama_index","slug":"self-class-name-does-not-provide-lazy-lo","errorCode":null,"errorMessage":"{self.__class__.__name__} does not provide lazy_load_data method currently","messagePattern":"(.+?) does not provide lazy_load_data method currently","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/readers/base.py","lineNumber":24,"sourceCode":"    TYPE_CHECKING,\n    Any,\n    Dict,\n    Iterable,\n    List,\n)\n\nif TYPE_CHECKING:  # pragma: no cover\n    from llama_index.core.bridge.langchain import Document as LCDocument  # type: ignore\nfrom llama_index.core.bridge.pydantic import ConfigDict, Field\nfrom llama_index.core.schema import BaseComponent, Document\n\n\nclass BaseReader(ABC):  # pragma: no cover\n    \"\"\"Utilities for loading data from a directory.\"\"\"\n\n    def lazy_load_data(self, *args: Any, **load_kwargs: Any) -> Iterable[Document]:\n        \"\"\"Load data from the input directory lazily.\"\"\"\n        raise NotImplementedError(\n            f\"{self.__class__.__name__} does not provide lazy_load_data method currently\"\n        )\n\n    async def alazy_load_data(\n        self, *args: Any, **load_kwargs: Any\n    ) -> Iterable[Document]:\n        \"\"\"Load data from the input directory lazily.\"\"\"\n        # Threaded async - just calls the sync method with to_thread. Override in subclasses for real async implementations.\n        return await asyncio.to_thread(self.lazy_load_data, *args, **load_kwargs)\n\n    def load_data(self, *args: Any, **load_kwargs: Any) -> List[Document]:\n        \"\"\"Load data from the input directory.\"\"\"\n        return list(self.lazy_load_data(*args, **load_kwargs))\n\n    async def aload_data(self, *args: Any, **load_kwargs: Any) -> List[Document]:\n        \"\"\"Load data from the input directory.\"\"\"\n        return await asyncio.to_thread(self.load_data, *args, **load_kwargs)\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/readers/base.py#L6-L42","documentation":"BaseReader declares lazy_load_data as the core data-loading primitive; the base implementation just raises NotImplementedError naming the subclass. load_data() in the base class delegates to lazy_load_data, so a reader that never implemented it fails at first load.","triggerScenarios":"Calling load_data() or lazy_load_data() on a custom BaseReader subclass that did not override lazy_load_data (or on a reader instance created via the abstract base directly).","commonSituations":"Writing a custom reader and overriding load_data but not lazy_load_data (the base load_data wraps lazy_load_data), or copy-pasting a reader skeleton without filling in the loader.","solutions":["Implement lazy_load_data(self, *args, **kwargs) -> Iterable[Document] in your subclass","Alternatively override load_data() directly if lazy iteration is not needed, though implementing lazy_load_data is the convention","Check you instantiated the intended reader class, not BaseReader or a bare skeleton"],"exampleFix":"// before\nclass MyReader(BaseReader):\n    def load_data(self, input_dir: str) -> list[Document]:\n        ...  # lazy_load_data never defined; base load_data path still raises\n\n// after\nclass MyReader(BaseReader):\n    def lazy_load_data(self, input_dir: str) -> Iterable[Document]:\n        for path in Path(input_dir).glob(\"*.txt\"):\n            yield Document(text=path.read_text())","handlingStrategy":"type-guard","validationCode":"from llama_index.core.readers.base import BaseReader\n\ndef reader_implements_lazy_load(reader: BaseReader) -> bool:\n    return type(reader).lazy_load_data is not BaseReader.lazy_load_data\n\nassert reader_implements_lazy_load(reader), \\\n    f\"{type(reader).__name__} never implemented lazy_load_data\"","typeGuard":"def is_loadable_reader(reader) -> bool:\n    \"\"\"True when the subclass actually implements lazy_load_data.\"\"\"\n    from llama_index.core.readers.base import BaseReader\n    return (\n        isinstance(reader, BaseReader)\n        and type(reader).lazy_load_data is not BaseReader.lazy_load_data\n    )","tryCatchPattern":null,"preventionTips":["In custom readers, implement lazy_load_data (yield Documents) — base load_data() builds on it","Add a smoke test that loads one file for every custom reader","Use getattr/type-level checks when dispatching over reader instances generically"],"tags":["reader","not-implemented","custom-reader","abstractmethod"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}