microsoft/graphrag · error · ValueError

Column name is None

Error message

Column name is None

What it means

The query input loader helpers (to_str, to_list, to_int, etc.) fetch a required column value from a mapping; if the column name itself is None and required=True, there is nothing to look up, so _get_value raises 'Column name is None'. Optional loaders (to_optional_str, etc.) pass required=False and return None instead.

Source

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

import numpy as np


def _get_value(
    data: Mapping[str, Any], column_name: str | None, required: bool = True
) -> Any:
    """
    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)

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Find which config/parameter resolved to None and set the column name
  2. If the column is genuinely optional, use the to_optional_* variant which tolerates None
  3. Default the column name: to_str(data, col or 'text')

Example fix

# before
text = to_str(row, col_name)  # col_name is None
# after
text = to_str(row, col_name or 'text')
# or, if optional:
text = to_optional_str(row, col_name)
Defensive patterns

Strategy: validation

Validate before calling

if col_name is None:
    col_name = 'text'  # or reject early
val = to_str(data, col_name)

Type guard

def has_column_name(c: object) -> bool:
    return isinstance(c, str) and len(c) > 0

Prevention

When it happens

Trigger: Calling to_str(data, None) or to_int(data, None) — i.e. passing a None column name to a required-value helper; usually happens when the column name comes from config that is unset.

Common situations: Readiding indexer artifacts where the config field for a column name was never set (None defaults); refactors that changed a parameter to Optional without switching to to_optional_str.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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