run-llama/llama_index · error · RuntimeError

Git command failed: {result.stderr}

Error message

Git command failed: {result.stderr}

What it means

Raised by json_to_doc in llama_index.core.storage.docstore.utils when deserializing a doc dict whose TYPE_KEY ('__type__') does not match any known type: Document, Node, TextNode, ImageNode, or IndexNode. It is the standard 'unknown __type__' failure when loading docstore records, meaning the persisted record was written by different code, a different library version, or hand-crafted with an invalid type tag.

Source

Thrown at llama-dev/llama_dev/utils.py:129


def find_all_packages(root_path: Path) -> list[Path]:
    """Returns a list of all the package folders in the monorepo."""
    return [
        root_path / "llama-index-core",
        *find_integrations(root_path),
        *find_utils(root_path),
        root_path / "llama-index-instrumentation",
    ]


def get_changed_files(repo_root: Path, base_ref: str = "main") -> list[Path]:
    """Use git to get the list of files changed compared to the base branch."""
    try:
        cmd = ["git", "diff", "--name-only", f"{base_ref}...HEAD"]
        result = subprocess.run(cmd, cwd=repo_root, text=True, capture_output=True)
        if result.returncode != 0:
            raise RuntimeError(f"Git command failed: {result.stderr}")

        return [repo_root / Path(f) for f in result.stdout.splitlines() if f.strip()]
    except Exception as e:
        print(f"Exception occurred: {e!s}")
        raise


def get_changed_packages(
    changed_files: list[Path], all_packages: list[Path]
) -> set[Path]:
    """Get the list of package folders containing the path in 'changed_files'."""
    changed_packages: set[Path] = set()

    for file_path in changed_files:
        # Find the package containing this file
        for pkg_dir in all_packages:
            if file_path.absolute().is_relative_to(pkg_dir.absolute()):
                changed_packages.add(pkg_dir)

View on GitHub (pinned to afd0fef371)

Solutions

  1. Inspect the persisted JSON and list the distinct __type__ values to find the invalid ones.
  2. If records come from a legacy version, route them through legacy_json_to_doc (which handles old formats) or re-persist from source documents.
  3. Re-ingest documents with your current llama-index version to regenerate a compatible docstore.
  4. If the type is from a custom node subclass, register it in your own fork of json_to_doc or store its fields under a supported base type (e.g. TextNode) with metadata.

Example fix

# before
# persisted docstore.json contains: {"__type__": "my_custom_node", ...}
store = SimpleDocumentStore.from_persist_path("docstore.json")  # ValueError: Unknown doc type

# after
# rewrite records to a supported type before loading
import json
with open("docstore.json") as f: data = json.load(f)
for k, rec in data["docs"].items():
    rec["__type__"] = rec["__type__"].replace("my_custom_node", "text")
with open("docstore.json", "w") as f: json.dump(data, f)
Defensive patterns

Strategy: validation

Validate before calling

KNOWN = {"document", "image_document", "text", "image", "index", "node"}
type_tag = rec.get("__type__")
if type_tag not in KNOWN:
    # rewrite record to "text"/"document" or drop before loading

Type guard

KNOWN_TYPES = {"document", "image_document", "text", "image", "index", "node"}

def is_known_doc_type(type_tag: str) -> bool:
    return type_tag in KNOWN_TYPES

Try / catch

try:
    doc = json_to_doc(rec)
except ValueError as e:
    if "Unknown doc type" in str(e):
        rec["__type__"] = "text"  # or quarantine the record
        doc = json_to_doc(rec)

Prevention

When it happens

Trigger: SimpleDocumentStore.from_persist_path loading a JSON whose entries have '__type__': 'agent_node' or any string outside the supported set; loading a docstore exported by a llama-index version that used different type keys; manually editing persisted docstore JSON and misspelling __type__.

Common situations: Major-version upgrades of llama-index (legacy 0.9 vs 0.10+ storage formats); loading a docstore file produced by a community integration or fork; cross-language writes into the same store; passing a QueryEngine/Response object dict where a node dict is expected.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/0e66194c2f460412. Report an issue: GitHub.