{"record":{"id":"4baaee6754c7fe6f","repo":"HKUDS/Vibe-Trading","slug":"path-row-row-number-date-raw-r-does-not-mat","errorCode":null,"errorMessage":"{path} row {row_number}: date {raw!r} does not match date_format={date_format!r}","messagePattern":"(.+?) row (.+?): date (.+?) does not match date_format=(.+?)","errorType":"exception","errorClass":"CashFlowIngestError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/ingest.py","lineNumber":253,"sourceCode":"        raw: Raw cell text.\n        date_format: ``strptime`` format, or ``None`` to require ISO-8601.\n        path: File path, used only for error messages.\n        row_number: 1-based data row number, used only for error messages.\n\n    Returns:\n        The parsed ``datetime.date``.\n\n    Raises:\n        CashFlowIngestError: If the cell is blank or does not parse.\n    \"\"\"\n    text = (raw or \"\").strip()\n    if not text:\n        raise CashFlowIngestError(f\"{path} row {row_number}: date is blank\")\n    if date_format:\n        try:\n            return datetime.strptime(text, date_format).date()\n        except ValueError as exc:\n            raise CashFlowIngestError(\n                f\"{path} row {row_number}: date {raw!r} does not match \"\n                f\"date_format={date_format!r}\"\n            ) from exc\n    try:\n        return normalize_date(text)\n    except ValueError as exc:\n        raise CashFlowIngestError(\n            f\"{path} row {row_number}: date {raw!r} is not ISO-8601 \"\n            \"(YYYY-MM-DD). Pass date_format=... explicitly; regional formats \"\n            \"are not guessed because day-first and month-first cannot be told \"\n            \"apart from the data.\"\n        ) from exc\n\n\ndef _read_rows(\n    path: Path, delimiter: str | None, encoding: str\n) -> tuple[list[str], list[dict[str, str]]]:\n    \"\"\"Read a delimited text file into a header and a list of row mappings.","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/ingest.py#L235-L271","documentation":"Raised by _parse_date when an explicit date_format was supplied but the cell does not match it under datetime.strptime. The message echoes both the raw value and the format string so the mismatch is immediately visible.","triggerScenarios":"load_cashflows(path, date_format='%m/%d/%Y') on a file containing '05/06/2024' mismatch or a value like '2024-01-05' when the format expects US ordering; any strptime-incompatible cell when date_format is non-None.","commonSituations":"Wrong format string for the actual export (e.g. %d/%m/%Y vs %m/%d/%Y); mixed-format rows in one file; format string with literal text (like 'T' or timezone suffix) missing; leading/trailing whitespace handled but internal mismatches not.","solutions":["Compare the raw value with the format string in the message and correct the format (e.g. add %H:%M or fix directive order)","If the file is actually ISO, drop date_format and let normalize_date handle it","If the file mixes formats, normalize dates in the source or split the file by format","Check for stray characters like weekday names or timezones and extend the format accordingly"],"exampleFix":"# before\nload_cashflows('us.csv', date_format='%d/%m/%Y')\n# after\nload_cashflows('us.csv', date_format='%m/%d/%Y')","handlingStrategy":"validation","validationCode":"from datetime import datetime\nsample = [r[date_col] for r in rows[:20] if r.get(date_col)]\nfor fmt in ('%m/%d/%Y', '%d/%m/%Y', '%Y-%m-%d'):\n    if all(try_strptime(v, fmt) for v in sample):\n        chosen = fmt; break\nelse:\n    raise ValueError('no single date_format fits sample')","typeGuard":"def matches_format(text: str, fmt: str) -> bool:\n    try:\n        datetime.strptime(text.strip(), fmt); return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    load_cashflows(p, date_format=fmt)\nexcept CashFlowIngestError as e:\n    if 'does not match date_format' in str(e):\n        fmt = infer_format_from_sample(p); load_cashflows(p, date_format=fmt)","preventionTips":["Probe a sample of dates with strptime to confirm the format before full load","Store the per-source date_format in config","Watch for rows that deviate from the file's dominant format"],"tags":["csv","date-parsing","strptime","format-mismatch"],"backgroundTag":"date-format-mismatch","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}