{"record":{"id":"c88173f902f10c7f","repo":"HKUDS/Vibe-Trading","slug":"path-mapped-column-source-name-r-for-field-f","errorCode":null,"errorMessage":"{path}: mapped column {source_name!r} for field {field_name!r} is not in the file. Columns present: {', '.join(header)}","messagePattern":"(.+?): mapped column (.+?) for field (.+?) is not in the file\\. Columns present: (.+?)","errorType":"exception","errorClass":"CashFlowIngestError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/ingest.py","lineNumber":120,"sourceCode":"        only fields that were actually found.\n\n    Raises:\n        CashFlowIngestError: If an explicit override names a column that the\n            file does not contain, or overrides an unknown field.\n    \"\"\"\n    resolved: dict[str, str] = {}\n    lookup = {_canonical(col): col for col in header}\n\n    if columns:\n        for field_name, source_name in columns.items():\n            if field_name not in DEFAULT_COLUMN_ALIASES:\n                known = \", \".join(sorted(DEFAULT_COLUMN_ALIASES))\n                raise CashFlowIngestError(\n                    f\"{path}: unknown column mapping {field_name!r}; \"\n                    f\"mappable fields are: {known}\"\n                )\n            if source_name not in header:\n                raise CashFlowIngestError(\n                    f\"{path}: mapped column {source_name!r} for field \"\n                    f\"{field_name!r} is not in the file. Columns present: \"\n                    f\"{', '.join(header)}\"\n                )\n            resolved[field_name] = source_name\n\n    for field_name, aliases in DEFAULT_COLUMN_ALIASES.items():\n        if field_name in resolved:\n            continue\n        for alias in aliases:\n            if alias in lookup:\n                resolved[field_name] = lookup[alias]\n                break\n\n    return resolved\n\n\ndef _to_plain_number(text: str, decimal_separator: str | None) -> str:","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/ingest.py#L102-L138","documentation":"Raised by _resolve_columns during cash-flow CSV ingestion when the user-supplied columns mapping names a source column that does not exist in the file's header row. The file was read successfully, but the explicit mapping points at a column name that is absent, so the field cannot be resolved. The message lists all columns actually present to help correct the mapping.","triggerScenarios":"Calling load_cashflows(path, columns={'date': 'TradeDate'}) (or load_panel with a columns mapping) where the header contains e.g. Date, Amount but not TradeDate. Any mapping value not found verbatim in the header triggers it.","commonSituations":"Typos in the mapping dict; column names with stray whitespace or a BOM prefix (﻿Date); case differences; mapping copied from a different export template; delimiter misdetected so multiple header cells merge into one name.","solutions":["Compare the mapping value against the 'Columns present' list in the message and fix the typo/whitespace exactly","Open the file and check for a BOM or padded header names; re-export or strip them","If the column genuinely has a different name, update the columns dict to that exact name","If the wrong delimiter split the header, pass delimiter=';' or delimiter='\\t' explicitly"],"exampleFix":"# before\nload_cashflows(p, columns={'date': 'TradeDate'})\n# after\nload_cashflows(p, columns={'date': ' TradeDate '.strip()})  # match exact header text","handlingStrategy":"validation","validationCode":"import csv\nfrom pathlib import Path\n\ndef check_mapping(path, columns, delimiter=None):\n    with open(path, newline='', encoding='utf-8-sig') as f:\n        header = next(csv.reader(f, delimiter=delimiter or ','))\n    bad = {field: src for field, src in columns.items() if src not in header}\n    if bad:\n        raise ValueError(f'mapping targets not in header: {bad}; header={header}')","typeGuard":"def mapping_is_valid(header: list[str], columns: dict[str, str]) -> bool:\n    return all(src in header for src in columns.values())","tryCatchPattern":"try:\n    load_cashflows(p, columns=cols)\nexcept CashFlowIngestError as e:\n    if 'not in the file' in str(e):\n        header = read_header(p)\n        cols = {f: match(h, header) for f, h in cols.items()}  # repair and retry once","preventionTips":["Read the header first and assert your mapping values exist before loading","Normalize header cells (strip, remove BOM) before comparing","Keep per-source column maps in config tested against fixture files"],"tags":["csv","ingest","column-mapping","cashflow"],"backgroundTag":"csv-column-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}