[Bug]: getting KeyError: '0' for retriever (critical breaking issue)

### Bug Description

I am using faiss index along with llamaindex version 0.12.27. 
My code looks like this:

retriever = index.as_retriever()
print(retriever.retrieve("<query>"))

-----------------------------------------------------------
this started throwing following error from past 2 days:

/databricks/python/lib/python3.9/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:184, in VectorIndexRetriever._insert_fetched_nodes_into_query_result(self, query_result, fetched_nodes)
    182 elif query_result.ids:
    183     for node_id in query_result.ids:
--> 184         new_nodes.append(fetched_nodes_by_id[node_id])
    185 else:
    186     raise ValueError(
    187         "Vector store query result should return at least one of nodes or ids."
    188     )


I suspect the root cause is : Refactor vector index retrieval (#19382), which is recently introduced in 0.12.49 (link: https://docs.llamaindex.ai/en/stable/CHANGELOG/#2025-07-14)

I have already tested in 0.12.27 and 0.12.49. it seems to be not working at all.

### Version

0.12.27

### Steps to Reproduce

1. create the faiss index using llamaindex - FaissVectorStore and persist it in azure databricks workspace folder.
2. call the index using : retriever = index.as_retriever()

### Relevant Logs/Tracbacks

```shell
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File <command-7466654490681187>:9
      7 # Test retrieval
      8 retriever = index.as_retriever()
----> 9 print(retriever.retrieve("stolen_vehicles and id"))

File /databricks/python/lib/python3.9/site-packages/llama_index_instrumentation/dispatcher.py:319, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    316             _logger.debug(f"Failed to reset active_span_id: {e}")
    318 try:
--> 319     result = func(*args, **kwargs)
    320     if isinstance(result, asyncio.Future):
    321         # If the result is a Future, wrap it
    322         new_future = asyncio.ensure_future(result)

File /databricks/python/lib/python3.9/site-packages/llama_index/core/base/base_retriever.py:246, in BaseRetriever.retrieve(self, str_or_query_bundle)
    241 with self.callback_manager.as_trace("query"):
    242     with self.callback_manager.event(
    243         CBEventType.RETRIEVE,
    244         payload={EventPayload.QUERY_STR: query_bundle.query_str},
    245     ) as retrieve_event:
--> 246         nodes = self._retrieve(query_bundle)
    247         nodes = self._handle_recursive_retrieval(query_bundle, nodes)
    248         retrieve_event.on_end(
    249             payload={EventPayload.NODES: nodes},
    250         )

File /databricks/python/lib/python3.9/site-packages/llama_index_instrumentation/dispatcher.py:319, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    316             _logger.debug(f"Failed to reset active_span_id: {e}")
    318 try:
--> 319     result = func(*args, **kwargs)
    320     if isinstance(result, asyncio.Future):
    321         # If the result is a Future, wrap it
    322         new_future = asyncio.ensure_future(result)

File /databricks/python/lib/python3.9/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:104, in VectorIndexRetriever._retrieve(self, query_bundle)
     98     if query_bundle.embedding is None and len(query_bundle.embedding_strs) > 0:
     99         query_bundle.embedding = (
    100             self._embed_model.get_agg_embedding_from_queries(
    101                 query_bundle.embedding_strs
    102             )
    103         )
--> 104 return self._get_nodes_with_embeddings(query_bundle)

File /databricks/python/lib/python3.9/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:218, in VectorIndexRetriever._get_nodes_with_embeddings(self, query_bundle_with_embeddings)
    213 # Fetch any missing nodes from the docstore and insert them into the query result
    214 fetched_nodes: List[BaseNode] = self._docstore.get_nodes(
    215     node_ids=self._determine_nodes_to_fetch(query_result), raise_error=False
    216 )
--> 218 query_result.nodes = self._insert_fetched_nodes_into_query_result(
    219     query_result, fetched_nodes
    220 )
    222 log_vector_store_query_result(query_result)
    224 return self._convert_nodes_to_scored_nodes(query_result)

File /databricks/python/lib/python3.9/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:184, in VectorIndexRetriever._insert_fetched_nodes_into_query_result(self, query_result, fetched_nodes)
    182 elif query_result.ids:
    183     for node_id in query_result.ids:
--> 184         new_nodes.append(fetched_nodes_by_id[node_id])
    185 else:
    186     raise ValueError(
    187         "Vector store query result should return at least one of nodes or ids."
    188     )

KeyError: '0'
```

Labels: bug, triage
State: closed