{"record":{"id":"0e66194c2f460412","repo":"run-llama/llama_index","slug":"git-command-failed-result-stderr","errorCode":null,"errorMessage":"Git command failed: {result.stderr}","messagePattern":"Git command failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"llama-dev/llama_dev/utils.py","lineNumber":129,"sourceCode":"\n\ndef find_all_packages(root_path: Path) -> list[Path]:\n    \"\"\"Returns a list of all the package folders in the monorepo.\"\"\"\n    return [\n        root_path / \"llama-index-core\",\n        *find_integrations(root_path),\n        *find_utils(root_path),\n        root_path / \"llama-index-instrumentation\",\n    ]\n\n\ndef get_changed_files(repo_root: Path, base_ref: str = \"main\") -> list[Path]:\n    \"\"\"Use git to get the list of files changed compared to the base branch.\"\"\"\n    try:\n        cmd = [\"git\", \"diff\", \"--name-only\", f\"{base_ref}...HEAD\"]\n        result = subprocess.run(cmd, cwd=repo_root, text=True, capture_output=True)\n        if result.returncode != 0:\n            raise RuntimeError(f\"Git command failed: {result.stderr}\")\n\n        return [repo_root / Path(f) for f in result.stdout.splitlines() if f.strip()]\n    except Exception as e:\n        print(f\"Exception occurred: {e!s}\")\n        raise\n\n\ndef get_changed_packages(\n    changed_files: list[Path], all_packages: list[Path]\n) -> set[Path]:\n    \"\"\"Get the list of package folders containing the path in 'changed_files'.\"\"\"\n    changed_packages: set[Path] = set()\n\n    for file_path in changed_files:\n        # Find the package containing this file\n        for pkg_dir in all_packages:\n            if file_path.absolute().is_relative_to(pkg_dir.absolute()):\n                changed_packages.add(pkg_dir)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-dev/llama_dev/utils.py#L111-L147","documentation":"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.","triggerScenarios":"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__.","commonSituations":"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.","solutions":["Inspect the persisted JSON and list the distinct __type__ values to find the invalid ones.","If records come from a legacy version, route them through legacy_json_to_doc (which handles old formats) or re-persist from source documents.","Re-ingest documents with your current llama-index version to regenerate a compatible docstore.","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."],"exampleFix":"# before\n# persisted docstore.json contains: {\"__type__\": \"my_custom_node\", ...}\nstore = SimpleDocumentStore.from_persist_path(\"docstore.json\")  # ValueError: Unknown doc type\n\n# after\n# rewrite records to a supported type before loading\nimport json\nwith open(\"docstore.json\") as f: data = json.load(f)\nfor k, rec in data[\"docs\"].items():\n    rec[\"__type__\"] = rec[\"__type__\"].replace(\"my_custom_node\", \"text\")\nwith open(\"docstore.json\", \"w\") as f: json.dump(data, f)","handlingStrategy":"validation","validationCode":"KNOWN = {\"document\", \"image_document\", \"text\", \"image\", \"index\", \"node\"}\ntype_tag = rec.get(\"__type__\")\nif type_tag not in KNOWN:\n    # rewrite record to \"text\"/\"document\" or drop before loading","typeGuard":"KNOWN_TYPES = {\"document\", \"image_document\", \"text\", \"image\", \"index\", \"node\"}\n\ndef is_known_doc_type(type_tag: str) -> bool:\n    return type_tag in KNOWN_TYPES","tryCatchPattern":"try:\n    doc = json_to_doc(rec)\nexcept ValueError as e:\n    if \"Unknown doc type\" in str(e):\n        rec[\"__type__\"] = \"text\"  # or quarantine the record\n        doc = json_to_doc(rec)","preventionTips":["Before from_persist_path, scan the JSON for unknown __type__ values.","Regenerate persisted stores with the current llama-index version instead of carrying old files forward.","Avoid hand-editing docstore JSON; if necessary, only use supported type tags."],"tags":["docstore","deserialization","version-mismatch","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}