{
  "id": "llm/llamaindex-persistence-corruption",
  "signature": "llama_index.core.storage.kvstore.simple_kvstore:ValueError: The 'index_store.json' file is corrupted or contains invalid JSON.",
  "signature_zh": "llama_index.core.storage.kvstore.simple_kvstore:ValueError: 'index_store.json'文件已损坏或包含无效的JSON。",
  "regex": "index_store\\.json.*corrupted|invalid JSON",
  "domain": "llm",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The LlamaIndex persistence file 'index_store.json' was partially written due to a crash, concurrent write, or disk full error, resulting in malformed JSON.",
  "root_cause_type": "generic",
  "root_cause_zh": "LlamaIndex持久化文件'index_store.json'因崩溃、并发写入或磁盘满错误而部分写入，导致JSON格式错误。",
  "versions": [
    {
      "version": "llama-index>=0.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "llama-index==0.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The file contains complex internal state; manual edits often break references between nodes and indices.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "LlamaIndex attempts to load the existing file first, and fails before overwriting.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Delete the corrupted persistence directory and rebuild the index from scratch:\nimport shutil\nimport os\n\npersist_dir = './storage'\nif os.path.exists(persist_dir):\n    shutil.rmtree(persist_dir)\n\n# Then rebuild index\nindex = VectorStoreIndex.from_documents(documents)\nindex.storage_context.persist(persist_dir=persist_dir)",
      "success_rate": 0.95,
      "how": "Delete the corrupted persistence directory and rebuild the index from scratch:\nimport shutil\nimport os\n\npersist_dir = './storage'\nif os.path.exists(persist_dir):\n    shutil.rmtree(persist_dir)\n\n# Then rebuild index\nindex = VectorStoreIndex.from_documents(documents)\nindex.storage_context.persist(persist_dir=persist_dir)",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you have a backup, restore the persistence directory from backup:\ncp -r ./storage_backup ./storage\n# Then validate\nfrom llama_index.core import StorageContext\nstorage_context = StorageContext.from_defaults(persist_dir='./storage')\nprint('Validation passed')",
      "success_rate": 0.85,
      "how": "If you have a backup, restore the persistence directory from backup:\ncp -r ./storage_backup ./storage\n# Then validate\nfrom llama_index.core import StorageContext\nstorage_context = StorageContext.from_defaults(persist_dir='./storage')\nprint('Validation passed')",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "删除损坏的持久化目录并从零开始重建索引：\nimport shutil\nimport os\n\npersist_dir = './storage'\nif os.path.exists(persist_dir):\n    shutil.rmtree(persist_dir)\n\n# 然后重建索引\nindex = VectorStoreIndex.from_documents(documents)\nindex.storage_context.persist(persist_dir=persist_dir)",
    "如果有备份，从备份恢复持久化目录：\ncp -r ./storage_backup ./storage\n# 然后验证\nfrom llama_index.core import StorageContext\nstorage_context = StorageContext.from_defaults(persist_dir='./storage')\nprint('验证通过')"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.llamaindex.ai/en/stable/module_guides/storing/persistence.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-09-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}