microsoft/graphrag · error · ValueError

Column [{column_name}] not found in data

Error message

Column [{column_name}] not found in data

What it means

_get_value raises this when required=True, the column name is a real string, but the key is absent from the data mapping. The loaders expect parquet/record rows from GraphRAG indexer outputs to contain specific columns; a missing key means the artifact schema doesn't match what the query path needs.

Source

Thrown at packages/graphrag/graphrag/query/input/loaders/utils.py:33

    """
    Retrieve a column value from data.

    If `required` is True, raises a ValueError when:
      - column_name is None, or
      - column_name is not in data.

    For optional columns (required=False), returns None if column_name is None.
    """
    if column_name is None:
        if required:
            msg = "Column name is None"
            raise ValueError(msg)
        return None
    if column_name in data:
        return data[column_name]
    if required:
        msg = f"Column [{column_name}] not found in data"
        raise ValueError(msg)
    return None


def to_str(data: Mapping[str, Any], column_name: str | None) -> str:
    """Convert and validate a value to a string."""
    value = _get_value(data, column_name, required=True)
    return str(value)


def to_optional_str(data: Mapping[str, Any], column_name: str | None) -> str | None:
    """Convert and validate a value to an optional string."""
    value = _get_value(data, column_name, required=True)
    return None if value is None else str(value)


def to_list(
    data: Mapping[str, Any], column_name: str | None, item_type: type | None = None
) -> list:

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Print sorted(data.keys()) and compare with the expected column list for that artifact type
  2. Regenerate the index with the matching GraphRAG version, or use the correct loader for that artifact type
  3. If the field is truly optional, switch to the to_optional_* helper

Example fix

# before
val = to_str(data, 'community_id')
# after
if 'community_id' not in data:
    raise KeyError(f'artifact missing community_id: {sorted(data.keys())}')
val = to_str(data, 'community_id')
Defensive patterns

Strategy: validation

Validate before calling

required = {'community', 'level', 'parent', 'children', 'text_unit_ids'}
missing = required - set(data.keys())
if missing:
    raise KeyError(f'artifact missing: {missing}')
val = to_str(data, 'community')

Type guard

def row_has(data: Mapping[str, Any], col: str) -> bool:
    return col in data

Prevention

When it happens

Trigger: Calling to_str(data, 'community_id') when 'community_id' is not a key in data; loading nodes/entities parquet missing an expected field; passing a dict row from a different GraphRAG version's output schema.

Common situations: Index artifacts generated by an older/newer GraphRAG version with renamed columns; manually truncated parquet files; querying an index built with different settings (e.g. missing embedding columns).

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/869abd45fd66db4d. Report an issue: GitHub.