# llama_index.core.storage.kvstore.simple_kvstore:ValueError: The 'index_store.json' file is corrupted or contains invalid JSON.

- **ID:** `llm/llamaindex-persistence-corruption`
- **Domain:** llm
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| llama-index>=0.10.0 | active | — | — |
| llama-index==0.9.0 | active | — | — |

## Workarounds

1. **Delete the corrupted persistence directory and rebuild the index from scratch:
import shutil
import os

persist_dir = './storage'
if os.path.exists(persist_dir):
    shutil.rmtree(persist_dir)

# Then rebuild index
index = VectorStoreIndex.from_documents(documents)
index.storage_context.persist(persist_dir=persist_dir)** (95% success)
   ```
   Delete the corrupted persistence directory and rebuild the index from scratch:
import shutil
import os

persist_dir = './storage'
if os.path.exists(persist_dir):
    shutil.rmtree(persist_dir)

# Then rebuild index
index = VectorStoreIndex.from_documents(documents)
index.storage_context.persist(persist_dir=persist_dir)
   ```
2. **If you have a backup, restore the persistence directory from backup:
cp -r ./storage_backup ./storage
# Then validate
from llama_index.core import StorageContext
storage_context = StorageContext.from_defaults(persist_dir='./storage')
print('Validation passed')** (85% success)
   ```
   If you have a backup, restore the persistence directory from backup:
cp -r ./storage_backup ./storage
# Then validate
from llama_index.core import StorageContext
storage_context = StorageContext.from_defaults(persist_dir='./storage')
print('Validation passed')
   ```

## Dead Ends

- **** — The file contains complex internal state; manual edits often break references between nodes and indices. (90% fail)
- **** — LlamaIndex attempts to load the existing file first, and fails before overwriting. (70% fail)
