microsoft/graphrag · error · TypeError
list item is not [{item_type}]: {v} ({type(v)})
Error message
list item is not [{item_type}]: {v} ({type(v)}) What it means
After to_list confirms the value is a list, it optionally validates each element against item_type (e.g. str for text_unit_ids, float for embeddings). Any element of the wrong type raises TypeError naming the expected type and the offending value — commonly a list of floats where ints/strings appear, or mixed-type lists after parquet deserialization.
Source
Thrown at packages/graphrag/graphrag/query/input/loaders/utils.py:63
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:
"""Convert and validate a value to a list."""
value = _get_value(data, column_name, required=True)
if isinstance(value, np.ndarray):
value = value.tolist()
if not isinstance(value, list):
msg = f"value is not a list: {value} ({type(value)})"
raise TypeError(msg)
if item_type is not None:
for v in value:
if not isinstance(v, item_type):
msg = f"list item is not [{item_type}]: {v} ({type(v)})"
raise TypeError(msg)
return value
def to_optional_list(
data: Mapping[str, Any], column_name: str | None, item_type: type | None = None
) -> list | None:
"""Convert and validate a value to an optional list."""
if column_name is None or column_name not in data:
return None
value = data[column_name]
if value is None:
return None
if isinstance(value, np.ndarray):
value = value.tolist()
if isinstance(value, str):
value = [value]
if not isinstance(value, list):
msg = f"value is not a list: {value} ({type(value)})"View on GitHub (pinned to f40e9a26ce)
Solutions
- Inspect the failing element (message includes value and type) and fix upstream data quality
- Coerce elements before validation: [str(x) for x in vals] or [float(x) for x in vals if x is not None]
- Drop or rebuild rows with None/corrupted list entries, usually by re-running the indexing step
Example fix
# before ids = to_list(row, 'text_unit_ids', item_type=str) # contains ints # after row['text_unit_ids'] = [str(x) for x in row['text_unit_ids']] ids = to_list(row, 'text_unit_ids', item_type=str)
Defensive patterns
Strategy: type-guard
Validate before calling
vals = data.get(col, [])
if item_type is str:
vals = [str(v) for v in vals]
elif item_type is float:
vals = [float(v) for v in vals if v is not None]
data = {**data, col: vals} Type guard
def all_of_type(vals: list, t: type) -> bool:
return all(isinstance(v, t) for v in vals) Try / catch
try:
vals = to_list(data, col, item_type=item_type)
except TypeError as e:
bad = [v for v in data[col] if not isinstance(v, item_type)]
logger.warning('bad items %r in %s', bad, col)
vals = [v for v in data[col] if isinstance(v, item_type)] Prevention
- Coerce id lists to a single scalar type before loading artifacts
- Re-run embedding/indexing for rows containing None entries
When it happens
Trigger: to_list(data, 'text_unit_ids', item_type=str) where the parquet column holds mixed types (some None or numeric ids); embedding lists containing None because of failed embeds; communities data where children ids were read as ints.
Common situations: Parquet/pandas coercing id lists to mixed object dtype; partially failed embedding runs leaving None entries; artifacts from different GraphRAG versions using numeric vs string ids.
Related errors
- Column name is None
- value is not a list: {value} ({type(value)})
- request_id needs to be passed as a keyword argument
- k must be an integer > 0
- Invalid Role: {value}
AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27).
Data as JSON: /api/errors/3569082b02223302.
Report an issue: GitHub.