{"record":{"id":"869abd45fd66db4d","repo":"microsoft/graphrag","slug":"column-column-name-not-found-in-data","errorCode":null,"errorMessage":"Column [{column_name}] not found in data","messagePattern":"Column \\[(.+?)\\] not found in data","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag/graphrag/query/input/loaders/utils.py","lineNumber":33,"sourceCode":"    \"\"\"\n    Retrieve a column value from data.\n\n    If `required` is True, raises a ValueError when:\n      - column_name is None, or\n      - column_name is not in data.\n\n    For optional columns (required=False), returns None if column_name is None.\n    \"\"\"\n    if column_name is None:\n        if required:\n            msg = \"Column name is None\"\n            raise ValueError(msg)\n        return None\n    if column_name in data:\n        return data[column_name]\n    if required:\n        msg = f\"Column [{column_name}] not found in data\"\n        raise ValueError(msg)\n    return None\n\n\ndef to_str(data: Mapping[str, Any], column_name: str | None) -> str:\n    \"\"\"Convert and validate a value to a string.\"\"\"\n    value = _get_value(data, column_name, required=True)\n    return str(value)\n\n\ndef to_optional_str(data: Mapping[str, Any], column_name: str | None) -> str | None:\n    \"\"\"Convert and validate a value to an optional string.\"\"\"\n    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:","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag/graphrag/query/input/loaders/utils.py#L15-L51","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Print sorted(data.keys()) and compare with the expected column list for that artifact type","Regenerate the index with the matching GraphRAG version, or use the correct loader for that artifact type","If the field is truly optional, switch to the to_optional_* helper"],"exampleFix":"# before\nval = to_str(data, 'community_id')\n# after\nif 'community_id' not in data:\n    raise KeyError(f'artifact missing community_id: {sorted(data.keys())}')\nval = to_str(data, 'community_id')","handlingStrategy":"validation","validationCode":"required = {'community', 'level', 'parent', 'children', 'text_unit_ids'}\nmissing = required - set(data.keys())\nif missing:\n    raise KeyError(f'artifact missing: {missing}')\nval = to_str(data, 'community')","typeGuard":"def row_has(data: Mapping[str, Any], col: str) -> bool:\n    return col in data","tryCatchPattern":null,"preventionTips":["Validate artifact schema once at load time, not per field","Keep producer and consumer GraphRAG versions in sync"],"tags":["graphrag","data-loading","schema","missing-key"],"backgroundTag":"missing-dataframe-column","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}