{"record":{"id":"1cef70d9e606dc86","repo":"run-llama/llama_index","slug":"summary-field-of-the-index-struct-not-set","errorCode":null,"errorMessage":"summary field of the index_struct not set.","messagePattern":"summary field of the index_struct not set\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/data_structs/data_structs.py","lineNumber":31,"sourceCode":"from dataclasses_json import DataClassJsonMixin\nfrom llama_index.core.data_structs.struct_type import IndexStructType\nfrom llama_index.core.schema import BaseNode, TextNode\n\n# TODO: legacy backport of old Node class\nNode = TextNode\n\n\n@dataclass\nclass IndexStruct(DataClassJsonMixin):\n    \"\"\"A base data struct for a LlamaIndex.\"\"\"\n\n    index_id: str = field(default_factory=lambda: str(uuid.uuid4()))\n    summary: Optional[str] = None\n\n    def get_summary(self) -> str:\n        \"\"\"Get text summary.\"\"\"\n        if self.summary is None:\n            raise ValueError(\"summary field of the index_struct not set.\")\n        return self.summary\n\n    @classmethod\n    @abstractmethod\n    def get_type(cls) -> IndexStructType:\n        \"\"\"Get index struct type.\"\"\"\n\n\n@dataclass\nclass IndexGraph(IndexStruct):\n    \"\"\"A graph representing the tree-structured index.\"\"\"\n\n    # mapping from index in tree to Node doc id.\n    all_nodes: Dict[int, str] = field(default_factory=dict)\n    root_nodes: Dict[int, str] = field(default_factory=dict)\n    node_id_to_children_ids: Dict[str, List[str]] = field(default_factory=dict)\n\n    @property","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/data_structs/data_structs.py#L13-L49","documentation":"Every persisted LlamaIndex index has an IndexStruct record carrying an optional text summary used to describe the index to the LLM (and to build retriever prompts). get_summary() refuses to return None: if the index struct was saved without a summary — typical for indexes built by very old versions or constructed by hand — it raises this ValueError.","triggerScenarios":"Calling index.index_struct.get_summary() (directly or via code paths like tree/graph index retrieval that embed the summary in a prompt) on an IndexStruct/IndexGraph/KeywordTable whose summary field was never set; loading a legacy storage_context.json that predates the summary field.","commonSituations":"Loading an index persisted by an old llama_index (pre-0.x rename) version where summary was not written; building IndexStruct dataclasses manually; loading an index someone else shared that was saved without a summary.","solutions":["Set a summary before use: index.index_struct.summary = 'summary text' (or pass summary=... when constructing the index struct)","When loading from old storage, use load_index_from_storage(storage_context) and then assign the summary yourself before querying","Rebuild the index from documents with VectorStoreIndex.from_documents(docs, summary='...') — modern builders fill summary automatically"],"exampleFix":"// before\nindex = load_index_from_storage(old_storage_context)\nindex.index_struct.get_summary()  # ValueError: summary not set\n\n// after\nindex = load_index_from_storage(old_storage_context)\nindex.index_struct.summary = \"Summary of my documents\"\nindex.index_struct.get_summary()  # ok","handlingStrategy":"validation","validationCode":"if index.index_struct.summary is None:\n    index.index_struct.summary = \"auto-generated summary\"  # set before use","typeGuard":"def has_summary(index_struct) -> bool:\n    return getattr(index_struct, \"summary\", None) is not None","tryCatchPattern":"try:\n    summary = index.index_struct.get_summary()\nexcept ValueError:\n    summary = \"(no summary available)\"  # and consider backfilling index.index_struct.summary","preventionTips":["Always pass a summary when building/persisting indexes (index.set(..., summary=...))","After load_index_from_storage on old data, check and backfill summary before querying","When sharing persisted indexes, re-save them with a current library version so summary is included"],"tags":["persistence","index","migration","data-model"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}