graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

[BUG] Bulk upload fails with IndexError: list index out of range during node resolution

Open farman-mk opened this issue 3 months ago • 3 comments

Bug Description

When attempting to bulk upload episodes with graphiti.add_episode_bulk(), the process fails with an IndexError: list index out of range during the resolve_extracted_nodes step.

Steps to Reproduce

Provide a minimal code example that reproduces the issue:

import asyncio
import json
import os
from datetime import datetime, timezone
from dotenv import load_dotenv
from graphiti_core import Graphiti
from graphiti_core.nodes import EpisodeType
from graphiti_core.utils.maintenance.graph_data_operations import clear_data
from graphiti_core.utils.bulk_utils import RawEpisode
from graphiti_core.llm_client.config import LLMConfig
from graphiti_core.llm_client import OpenAIClient

# Load environment variables
load_dotenv()

neo4j_uri = os.environ.get('NEO4J_URI', 'bolt://localhost:7687')
neo4j_user = os.environ.get('NEO4J_USER', 'neo4j')
neo4j_password = os.environ.get('NEO4J_PASSWORD', 'password')

user_data = [
    {
        "name": "Adeel Solangi",
        "language": "Sindhi",
        "id": "V59OF92YF627HFY0",
        "bio": "Sample bio text.",
        "version": 6.1
    },
    {
        "name": "Afzal Ghaffar",
        "language": "Sindhi",
        "id": "ENTOCR13RSCLZ6KU",
        "bio": "Another bio text.",
        "version": 1.88
    }
]

async def bulk_upload():
    llm_config = LLMConfig(
        api_key=os.getenv("OPENAI_API_KEY", "password"),
        model="gpt-4o-mini",
        base_url="https://api.openai.com/v1",
        small_model="gpt-4o-mini"
    )

    graphiti = Graphiti(neo4j_uri, neo4j_user, neo4j_password, llm_client=OpenAIClient(config=llm_config))
    try:
        await graphiti.build_indices_and_constraints()
        await clear_data(graphiti.driver)
        print("Graph data cleared successfully.")

        bulk_episodes = [
            RawEpisode(
                name=f"User Data - {user['name']}",
                content=json.dumps({k: str(v) if isinstance(v, int) else v for k, v in user.items()}),
                source=EpisodeType.json,
                source_description="User metadata bulk upload",
                reference_time=datetime.now(timezone.utc)
            )
            for user in user_data
        ]

        await graphiti.add_episode_bulk(bulk_episodes)
        print(f"✅ Successfully uploaded {len(bulk_episodes)} episodes in bulk.")

    finally:
        await graphiti.close()
        print("Connection closed.")

if __name__ == "__main__":
    asyncio.run(bulk_upload())

Expected Behavior

A clear and concise description of what you expected to happen.

Actual Behavior

A clear and concise description of what actually happened.

Environment

  • Graphiti Version: 0.18.9]
  • Python Version: [3.12.6]
  • Operating System: [window 11]
  • Database Backend: [e.g. Neo4j 5.26, FalkorDB 1.1.2]
  • LLM Provider & Model: [ OpenAI gpt-4.1-mini]

Installation Method

  • [ ] pip install

Error Messages/Traceback

IndexError: list index out of range
Traceback (most recent call last):
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\bulk_episode.py", line 484, in <module>
    asyncio.run(bulk_upload())
  File "C:\Users\Farman\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Farman\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Farman\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\bulk_episode.py", line 476, in bulk_upload
    await graphiti.add_episode_bulk(bulk_episodes)
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\env\Lib\site-packages\graphiti_core\graphiti.py", line 853, in add_episode_bulk
    raise e
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\env\Lib\site-packages\graphiti_core\graphiti.py", line 755, in add_episode_bulk
    node_results = await semaphore_gather(
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\env\Lib\site-packages\graphiti_core\helpers.py", line 121, in semaphore_gather
    return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\env\Lib\site-packages\graphiti_core\helpers.py", line 119, in _wrap_coroutine
    return await coroutine
           ^^^^^^^^^^^^^^^
  File "C:\Users\Farman\Downloads\ottomator-agents-main\ottomator-agents-main\graphiti-agent\env\Lib\site-packages\graphiti_core\utils\maintenance\node_operations.py", line 272, in resolve_extracted_nodes
    extracted_node = extracted_nodes[resolution_id]
                     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
IndexError: list index out of range
sys:1: RuntimeWarning: coroutine 'resolve_extracted_nodes' was never awaited

Configuration

# Relevant configuration or initialization code

Additional Context

This error happens consistently with any test dataset.

Tested after clearing the graph with clear_data() before upload.

Same error occurs whether integers are stringified or not.

Possible Solution

If you have ideas about what might be causing the issue or how to fix it, please share them here.

farman-mk avatar Aug 29 '25 20:08 farman-mk

I resolve this problem when i change gpt-4o-mini to gpt5

    llm_config = LLMConfig(
        api_key=os.getenv("OPENAI_API_KEY", "password"),
        model="gpt-5",
        base_url="https://api.openai.com/v1",
        small_model="gpt-5"
    )
Image

Bit-urd avatar Sep 07 '25 18:09 Bit-urd

@farman-mk Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Oct 12 '25 00:10 claude[bot]

@farman-mk Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Nov 17 '25 00:11 claude[bot]