{"record":{"id":"1da8064cd91e078e","repo":"run-llama/llama_index","slug":"indices-and-index-summaries-must-have-same-length","errorCode":null,"errorMessage":"indices and index_summaries must have same length!","messagePattern":"indices and index_summaries must have same length!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/composability/graph.py","lineNumber":80,"sourceCode":"                    if index.index_struct.summary is None:\n                        raise ValueError(\n                            \"Summary must be set for children indices. \"\n                            \"If the index does a summary \"\n                            \"(through index.index_struct.summary), then \"\n                            \"it must be specified with then `index_summaries` \"\n                            \"argument in this function. We will support \"\n                            \"automatically setting the summary in the future.\"\n                        )\n                index_summaries = [\n                    index.index_struct.summary for index in children_indices\n                ]\n            else:\n                # set summaries for each index\n                for index, summary in zip(children_indices, index_summaries):\n                    index.index_struct.summary = summary\n\n            if len(children_indices) != len(index_summaries):\n                raise ValueError(\"indices and index_summaries must have same length!\")\n\n            # construct index nodes\n            index_nodes = []\n            for index, summary in zip(children_indices, index_summaries):\n                assert isinstance(index.index_struct, IndexStruct)\n                index_node = IndexNode(\n                    text=summary,\n                    index_id=index.index_id,\n                    relationships={\n                        NodeRelationship.SOURCE: RelatedNodeInfo(\n                            node_id=index.index_id, node_type=ObjectType.INDEX\n                        )\n                    },\n                )\n                index_nodes.append(index_node)\n\n            # construct root index\n            root_index = root_index_cls(","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/composability/graph.py#L62-L98","documentation":"ComposableGraph.from_indices zips children_indices with index_summaries one-to-one. After the summary-setting loop it asserts len(children_indices) == len(index_summaries) and raises ValueError on mismatch. This catches partial summary lists and off-by-one construction errors before corrupt IndexNodes get built.","triggerScenarios":"Passing three child indexes with two index_summaries (or vice versa); generating summaries programmatically where one iteration is skipped; hard-coded summary lists drifting out of sync after adding an index.","commonSituations":"Maintaining a fixed index_summaries list while adding/removing child indexes over time; mapping/filtering the indices list but forgetting to apply the same transformation to summaries.","solutions":["Make summary generation structural: index_summaries = [f'Summary for {i}' for i in sources] derived from the same loop that builds indices.","Add an explicit assert len(indices) == len(index_summaries) before calling from_indices so failures surface with your own context.","Store summaries alongside index configs in one data structure (list of (index, summary) tuples) so they cannot diverge."],"exampleFix":"# before\nindices = [sales_idx, hr_idx, legal_idx]\nsummaries = [\"Sales data\", \"HR policies\"]  # 3 vs 2 -> ValueError\ngraph = ComposableGraph.from_indices(TreeIndex, indices, index_summaries=summaries)\n\n# after\nindex_defs = [(sales_idx, \"Sales data\"), (hr_idx, \"HR policies\"), (legal_idx, \"Legal contracts\")]\ngraph = ComposableGraph.from_indices(\n    TreeIndex,\n    [i for i, _ in index_defs],\n    index_summaries=[s for _, s in index_defs],\n)","handlingStrategy":"validation","validationCode":"assert len(children_indices) == len(index_summaries), (\n    f\"{len(children_indices)} indices vs {len(index_summaries)} summaries\"\n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build indices and summaries from one list of (index, summary) tuples.","Add a pre-call length assert so mismatches fail with your own diagnostics."],"tags":["composable-graph","validation","length-mismatch"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}