{"record":{"id":"3569082b02223302","repo":"microsoft/graphrag","slug":"list-item-is-not-item-type-v-type-v","errorCode":null,"errorMessage":"list item is not [{item_type}]: {v} ({type(v)})","messagePattern":"list item is not \\[(.+?)\\]: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/graphrag/graphrag/query/input/loaders/utils.py","lineNumber":63,"sourceCode":"    value = _get_value(data, column_name, required=True)\n    return None if value is None else str(value)\n\n\ndef to_list(\n    data: Mapping[str, Any], column_name: str | None, item_type: type | None = None\n) -> list:\n    \"\"\"Convert and validate a value to a list.\"\"\"\n    value = _get_value(data, column_name, required=True)\n    if isinstance(value, np.ndarray):\n        value = value.tolist()\n    if not isinstance(value, list):\n        msg = f\"value is not a list: {value} ({type(value)})\"\n        raise TypeError(msg)\n    if item_type is not None:\n        for v in value:\n            if not isinstance(v, item_type):\n                msg = f\"list item is not [{item_type}]: {v} ({type(v)})\"\n                raise TypeError(msg)\n    return value\n\n\ndef to_optional_list(\n    data: Mapping[str, Any], column_name: str | None, item_type: type | None = None\n) -> list | None:\n    \"\"\"Convert and validate a value to an optional list.\"\"\"\n    if column_name is None or column_name not in data:\n        return None\n    value = data[column_name]\n    if value is None:\n        return None\n    if isinstance(value, np.ndarray):\n        value = value.tolist()\n    if isinstance(value, str):\n        value = [value]\n    if not isinstance(value, list):\n        msg = f\"value is not a list: {value} ({type(value)})\"","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag/graphrag/query/input/loaders/utils.py#L45-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nids = to_list(row, 'text_unit_ids', item_type=str)  # contains ints\n# after\nrow['text_unit_ids'] = [str(x) for x in row['text_unit_ids']]\nids = to_list(row, 'text_unit_ids', item_type=str)","handlingStrategy":"type-guard","validationCode":"vals = data.get(col, [])\nif item_type is str:\n    vals = [str(v) for v in vals]\nelif item_type is float:\n    vals = [float(v) for v in vals if v is not None]\ndata = {**data, col: vals}","typeGuard":"def all_of_type(vals: list, t: type) -> bool:\n    return all(isinstance(v, t) for v in vals)","tryCatchPattern":"try:\n    vals = to_list(data, col, item_type=item_type)\nexcept TypeError as e:\n    bad = [v for v in data[col] if not isinstance(v, item_type)]\n    logger.warning('bad items %r in %s', bad, col)\n    vals = [v for v in data[col] if isinstance(v, item_type)]","preventionTips":["Coerce id lists to a single scalar type before loading artifacts","Re-run embedding/indexing for rows containing None entries"],"tags":["graphrag","data-loading","type-error","validation"],"backgroundTag":"type-validation-failed","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}