HKUDS/Vibe-Trading · error · CashFlowIngestError
{path} row {row_number}: date {raw!r} does not match date_fo
Error message
{path} row {row_number}: date {raw!r} does not match date_format={date_format!r} What it means
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.
Source
Thrown at agent/src/entities/ingest.py:253
raw: Raw cell text.
date_format: ``strptime`` format, or ``None`` to require ISO-8601.
path: File path, used only for error messages.
row_number: 1-based data row number, used only for error messages.
Returns:
The parsed ``datetime.date``.
Raises:
CashFlowIngestError: If the cell is blank or does not parse.
"""
text = (raw or "").strip()
if not text:
raise CashFlowIngestError(f"{path} row {row_number}: date is blank")
if date_format:
try:
return datetime.strptime(text, date_format).date()
except ValueError as exc:
raise CashFlowIngestError(
f"{path} row {row_number}: date {raw!r} does not match "
f"date_format={date_format!r}"
) from exc
try:
return normalize_date(text)
except ValueError as exc:
raise CashFlowIngestError(
f"{path} row {row_number}: date {raw!r} is not ISO-8601 "
"(YYYY-MM-DD). Pass date_format=... explicitly; regional formats "
"are not guessed because day-first and month-first cannot be told "
"apart from the data."
) from exc
def _read_rows(
path: Path, delimiter: str | None, encoding: str
) -> tuple[list[str], list[dict[str, str]]]:
"""Read a delimited text file into a header and a list of row mappings.View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before
load_cashflows('us.csv', date_format='%d/%m/%Y')
# after
load_cashflows('us.csv', date_format='%m/%d/%Y') Defensive patterns
Strategy: validation
Validate before calling
from datetime import datetime
sample = [r[date_col] for r in rows[:20] if r.get(date_col)]
for fmt in ('%m/%d/%Y', '%d/%m/%Y', '%Y-%m-%d'):
if all(try_strptime(v, fmt) for v in sample):
chosen = fmt; break
else:
raise ValueError('no single date_format fits sample') Type guard
def matches_format(text: str, fmt: str) -> bool:
try:
datetime.strptime(text.strip(), fmt); return True
except ValueError:
return False Try / catch
try:
load_cashflows(p, date_format=fmt)
except CashFlowIngestError as e:
if 'does not match date_format' in str(e):
fmt = infer_format_from_sample(p); load_cashflows(p, date_format=fmt) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {path} row {row_number}: date is blank
- {path}: unknown column mapping {field_name!r}; mappable fiel
- {path}: mapped column {source_name!r} for field {field_name!
- {text!r} uses a single comma and could be either {text.repla
- {path} row {row_number}: amount is blank. A missing amount m
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/4baaee6754c7fe6f.
Report an issue: GitHub.