run-llama/llama_index · error · RuntimeError

Command failed: {command} {result.stderr}

Error message

Command failed: {command}
{result.stderr}

What it means

Async twin of the get_node type check: raised by BaseDocumentStore.aget_node when aget_document returns a non-None object that fails isinstance(doc, BaseNode). This means the docstore contains data under that id, but it deserialized to something other than a BaseNode — corrupted rows, raw dicts, or an incompatible schema from another library version or an external writer.

Source

Thrown at llama-dev/llama_dev/release/changelog.py:20

import re
import shlex
import subprocess
from datetime import date
from pathlib import Path

import click

from llama_dev.utils import find_all_packages, get_changed_packages, load_pyproject

CHANGELOG_PLACEHOLDER = "<!--- generated changelog --->"


def _run_command(command: str) -> str:
    """Helper to run a shell command and return the output."""
    args = shlex.split(command)
    result = subprocess.run(args, capture_output=True, text=True)
    if result.returncode != 0:
        raise RuntimeError(f"Command failed: {command}\n{result.stderr}")
    return result.stdout.strip()


def _get_latest_tag() -> str:
    """Get the most recent tag with the form v1.2.3"""
    return _run_command('git describe --tags --match "v[0-9]*" --abbrev=0')


def _get_pr_numbers(latest_tag: str) -> set[str]:
    """Get the list of PR numbers merged between `latest_tag` and HEAD"""
    log_output = _run_command(f'git log {latest_tag}..HEAD --pretty="format:%H %s"')
    pr_numbers = set()
    pr_pattern = re.compile(r"\(#(\d+)\)")
    for line in log_output.splitlines():
        match = pr_pattern.search(line)
        if match:
            pr_numbers.add(match.group(1))

View on GitHub (pinned to afd0fef371)

Solutions

  1. Check the raw stored payload: print(type(await docstore.aget_document(node_id, raise_error=False))) and inspect its '__type__' field.
  2. Rewrite the offending entries as proper BaseNode objects through add_documents so they serialize via doc_to_dict.
  3. Re-ingest source documents into a fresh docstore if the data is from an incompatible version.
  4. Align all writers/readers to the same llama-index version so doc_type keys match the registry in utils.py.

Example fix

# before
obj = await docstore.aget_node(node_id)  # ValueError: Document ... is not a Node.

# after
obj = await docstore.aget_document(node_id, raise_error=False)
if not isinstance(obj, BaseNode):
    from llama_index.core.storage.docstore.utils import json_to_doc
    obj = json_to_doc(obj) if isinstance(obj, dict) else None
# then re-store obj via add_documents
Defensive patterns

Strategy: type-guard

Validate before calling

doc = await docstore.aget_document(node_id, raise_error=False)
if not isinstance(doc, BaseNode):
    # avoid aget_node; repair the record first
    ...

Type guard

from llama_index.core.schema import BaseNode

def is_valid_stored(doc) -> bool:
    return isinstance(doc, BaseNode)

Try / catch

try:
    node = await docstore.aget_node(node_id)
except ValueError as e:
    if "not a Node" in str(e):
        # repair: deserialize raw payload and re-add
        ...

Prevention

When it happens

Trigger: Awaiting aget_node on an id whose stored payload is a plain dict or legacy-format record that json_to_doc/legacy_json_to_doc could not map to a known node type; a custom store whose aget_document bypasses llama-index deserialization; docstore JSON files shared between different llama-index major versions.

Common situations: Persisted storage reused after upgrading llama-index; multiple writers (some storing raw payloads) sharing a KV collection; typos in TYPE_KEY values when hand-editing persisted docstore JSON; mixing docstore collections between Document and node data.

Related errors


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