run-llama/llama_index · error · ValueError
Failed to load index with ID {index_id}
Error message
Failed to load index with ID {index_id} What it means
In load_indices_from_storage, when explicit index_ids are supplied, each id is looked up via storage_context.index_store.get_index_struct(index_id). A None return means no index struct with that id exists in the loaded index store, and the loop raises ValueError('Failed to load index with ID {index_id}').
Source
Thrown at llama-index-core/llama_index/core/indices/loading.py:75
Args:
storage_context (StorageContext): storage context containing
docstore, index store and vector store.
index_id (Optional[Sequence[str]]): IDs of the indices to load.
Defaults to None, which loads all indices in the index store.
**kwargs: Additional keyword args to pass to the index constructors.
"""
if index_ids is None:
logger.info("Loading all indices.")
index_structs = storage_context.index_store.index_structs()
else:
logger.info(f"Loading indices with ids: {index_ids}")
index_structs = []
for index_id in index_ids:
index_struct = storage_context.index_store.get_index_struct(index_id)
if index_struct is None:
raise ValueError(f"Failed to load index with ID {index_id}")
index_structs.append(index_struct)
indices = []
for index_struct in index_structs:
type_ = index_struct.get_type()
index_cls = INDEX_STRUCT_TYPE_TO_INDEX_CLASS[type_]
index = index_cls(
index_struct=index_struct, storage_context=storage_context, **kwargs
)
indices.append(index)
return indices
def load_graph_from_storage(
storage_context: StorageContext,
root_id: str,
**kwargs: Any,
) -> ComposableGraph:View on GitHub (pinned to afd0fef371)
Solutions
- List the ids actually present and use one of them: ids = [s.index_id for s in storage_context.index_store.index_structs()].
- Persist/track index ids at build time (index.index_id) alongside the storage dir so loaders reference the right one.
- If no ids are known, omit index_id and use load_indices_from_storage to load everything, then choose by index type (index_struct.get_type()).
Example fix
# before index = load_index_from_storage(storage_context, index_id="my-old-id") # after valid_ids = [s.index_id for s in storage_context.index_store.index_structs()] index = load_index_from_storage(storage_context, index_id=valid_ids[0])
Defensive patterns
Strategy: validation
Validate before calling
valid_ids = {s.index_id for s in storage_context.index_store.index_structs()}
assert index_id in valid_ids, f"{index_id} not in persisted ids: {valid_ids}"
index = load_index_from_storage(storage_context, index_id=index_id) Try / catch
try:
index = load_index_from_storage(storage_context, index_id=index_id)
except ValueError as e:
if "Failed to load index with ID" in str(e):
valid = [s.index_id for s in storage_context.index_store.index_structs()]
raise RuntimeError(f"index_id stale; available: {valid}") from e
raise Prevention
- Read index ids from index_store.index_structs() instead of hardcoding.
- Persist index_id metadata with your storage artifacts.
- Treat index_id as environment-scoped: never share ids across dev/prod dirs.
When it happens
Trigger: Calling load_index_from_storage(storage_context, index_id='...') with a stale, mistyped, or wrong-environment id; passing a node id or doc id instead of the index id; storage persisted after the index was rebuilt under a new id.
Common situations: Hardcoding an index_id that changed after a re-index; environments (dev/prod) sharing config but not storage; ids truncated or copied incorrectly; storage dir overwritten by a fresh build.
Related errors
- Expected to load a single index, but got {len(indices)} inst
- No index in storage context, check if you specified the righ
- Max iterations of {max_iterations} reached! Either something
- CitableBlock content must contain exactly one block when pro
- Eval mode {eval_mode} not supported.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/4c084bddc3d9474c.
Report an issue: GitHub.