{"record":{"id":"9af3b93f72b96f86","repo":"HKUDS/Vibe-Trading","slug":"path-unknown-column-mapping-field-name-r-map","errorCode":null,"errorMessage":"{path}: unknown column mapping {field_name!r}; mappable fields are: {known}","messagePattern":"(.+?): unknown column mapping (.+?); mappable fields are: (.+?)","errorType":"exception","errorClass":"CashFlowIngestError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/ingest.py","lineNumber":115,"sourceCode":"        columns: Explicit overrides, canonical field -> file column name.\n        path: File path, used only for error messages.\n\n    Returns:\n        Mapping of canonical field name to the file's column name, containing\n        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","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/ingest.py#L97-L133","documentation":"load_cashflows' columns= argument maps canonical field names to header names; only names present in DEFAULT_COLUMN_ALIASES are mappable. An unrecognized field name raises CashFlowIngestError listing the valid fields.","triggerScenarios":"load_cashflows('flows.csv', columns={'amnt': 'Amount'}) — 'amnt' is not a canonical field; only names like date, kind, amount, currency (per DEFAULT_COLUMN_ALIASES) are accepted.","commonSituations":"Guessing field names instead of checking the schema; renaming source columns and passing the new name as the dict key instead of the value; version differences that added/renamed mappable fields.","solutions":["Use only canonical field names as keys, with the CSV header as the value: columns={'amount': 'Net Amount'}","If the field you want isn't mappable, map an existing canonical field to the header that carries that data","Check the error's listed 'mappable fields are:' set for the exact valid keys"],"exampleFix":"# before\nload_cashflows('f.csv', columns={'amnt': 'Amount'})\n# after\nload_cashflows('f.csv', columns={'amount': 'Amount'})","handlingStrategy":"validation","validationCode":"from agent.src.entities.ingest import DEFAULT_COLUMN_ALIASES\nassert set(columns) <= set(DEFAULT_COLUMN_ALIASES), f'bad keys: {set(columns) - set(DEFAULT_COLUMN_ALIASES)}'","typeGuard":null,"tryCatchPattern":"try:\n    load_cashflows(path, columns=columns)\nexcept CashFlowIngestError as e:\n    if 'unknown column mapping' in str(e):\n        columns = {k: v for k, v in columns.items() if k in DEFAULT_COLUMN_ALIASES}","preventionTips":["Keep mapping keys = canonical field names; values = CSV headers","Pin and read DEFAULT_COLUMN_ALIASES programmatically instead of hard-coding names","Add a smoke test that loads a sample CSV with the production mapping"],"tags":["python","csv","ingest","column-mapping"],"backgroundTag":"invalid-column-mapping","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}