{"record":{"id":"dc29e56d6d3b68bc","repo":"run-llama/llama_index","slug":"must-specify-class-name-in-reader-data","errorCode":null,"errorMessage":"Must specify `class_name` in reader data.","messagePattern":"Must specify `class_name` in reader data\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/readers/loading.py","lineNumber":18,"sourceCode":"from typing import Any, Dict, Type\n\nfrom llama_index.core.readers.base import BasePydanticReader\nfrom llama_index.core.readers.string_iterable import StringIterableReader\n\nALL_READERS: Dict[str, Type[BasePydanticReader]] = {\n    StringIterableReader.class_name(): StringIterableReader,\n}\n\n\ndef load_reader(data: Dict[str, Any]) -> BasePydanticReader:\n    if isinstance(data, BasePydanticReader):\n        return data\n\n    class_name = data.get(\"class_name\")\n\n    if class_name is None:\n        raise ValueError(\"Must specify `class_name` in reader data.\")\n\n    if class_name not in ALL_READERS:\n        raise ValueError(f\"Reader class name {class_name} not found.\")\n\n    # remove static attribute\n    data.pop(\"is_remote\", None)\n\n    return ALL_READERS[class_name].from_dict(data)\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/readers/loading.py#L1-L27","documentation":"load_reader(data) deserializes a reader from a dict and requires a 'class_name' key to look up the class in the ALL_READERS registry. This ValueError is thrown when the dict has no 'class_name' entry (None). It is the standard entry point when restoring reader configs from JSON/persisted indexes or documents.","triggerScenarios":"Calling load_reader({...}) on a hand-built dict that omits class_name; loading a document whose metadata/reader field was serialized by older code or a different library that did not include class_name; passing a partially constructed dict after popping or renaming keys.","commonSituations":"Round-tripping Document.reader through to_dict/from_dict across versions; storing reader configs in a database and dropping the class_name field; manual construction of reader payloads in pipelines.","solutions":["Add 'class_name' to the payload before calling load_reader, e.g. data['class_name'] = 'StringIterableReader' (the name the reader's class_name() method returns).","If serializing yourself, use reader.to_dict() so class_name is included automatically, instead of building the dict by hand.","Upgrade/downgrade alignment: ensure the code that produced the dict and the code that reads it use the same llama-index version."],"exampleFix":"# before\ndata = {\"iterable\": [\"a\", \"b\"]}  # no class_name\nreader = load_reader(data)\n\n# after\ndata = {\"class_name\": \"StringIterableReader\", \"iterable\": [\"a\", \"b\"]}\nreader = load_reader(data)","handlingStrategy":"validation","validationCode":"def is_valid_reader_payload(data: dict) -> bool:\n    return isinstance(data, dict) and \"class_name\" in data and data[\"class_name\"]","typeGuard":"def is_valid_reader_payload(data: dict) -> bool:\n    return isinstance(data, dict) and bool(data.get(\"class_name\"))","tryCatchPattern":"try:\n    reader = load_reader(data)\nexcept ValueError as e:\n    if \"class_name\" in str(e):\n        raise ValueError(f\"serialized reader payload missing class_name: {data}\") from e\n    raise","preventionTips":["Always serialize readers with reader.to_dict() rather than building dicts by hand.","Schema-check persisted payloads for the class_name key at load time."],"tags":["serialization","deserialization","readers","config"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}