{"record":{"id":"bc85f9b112dd5fbd","repo":"HKUDS/Vibe-Trading","slug":"path-row-row-number-amount-raw-r-is-not-usa","errorCode":null,"errorMessage":"{path} row {row_number}: amount {raw!r} is not usable: {exc}","messagePattern":"(.+?) row (.+?): amount (.+?) is not usable: (.+?)","errorType":"exception","errorClass":"CashFlowIngestError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/ingest.py","lineNumber":220,"sourceCode":"    \"\"\"\n    text = (raw or \"\").strip()\n    if not text:\n        raise CashFlowIngestError(\n            f\"{path} row {row_number}: amount is blank. A missing amount must be \"\n            \"fixed at the source; it is not treated as zero.\"\n        )\n\n    negative = text.startswith(\"(\") and text.endswith(\")\")\n    if negative:\n        text = text[1:-1]\n    text = \"\".join(ch for ch in text if ch not in _AMOUNT_SYMBOLS).strip()\n    if text.endswith(\"-\"):  # trailing-minus exports\n        text = \"-\" + text[:-1]\n\n    try:\n        value = float(_to_plain_number(text, decimal_separator))\n    except ValueError as exc:\n        raise CashFlowIngestError(\n            f\"{path} row {row_number}: amount {raw!r} is not usable: {exc}\"\n        ) from exc\n    return -value if negative else value\n\n\ndef _parse_date(\n    raw: str,\n    date_format: str | None,\n    path: Path,\n    row_number: int,\n) -> date:\n    \"\"\"Parse a date cell, using an explicit format when one is supplied.\n\n    Args:\n        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.","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/ingest.py#L202-L238","documentation":"Raised by _parse_amount when the amount cell cannot be converted to a float after normalization; the inner exception text describes the exact problem (e.g. leftover symbols, letters, or malformed grouping). The raw cell content is included for diagnosis.","triggerScenarios":"An amount cell like 'USD 100', '1.2.3', 'abc', '(12,34' (unbalanced parentheses leave stray characters), or a trailing-minus form that still fails float() after _to_plain_number processing, passed through load_cashflows/_parse_panel_amount.","commonSituations":"Exports that embed currency codes or footnote markers in the amount column; copy-pasted spreadsheet cells with non-breaking spaces; partially-applied accounting formats; scientific/odd notation the normalizer doesn't handle.","solutions":["Look at the raw value in the message and the inner exc text; strip non-numeric decoration in the source or a preprocessing pass","Fix malformed values such as double dots or stray characters at the source","If values use a locale format, also pass decimal_separator appropriately","Add a pre-load cleaning step (regex strip of currency symbols/spaces) before load_cashflows"],"exampleFix":"# before: cell is 'USD 1,234.56'\nload_cashflows('flows.csv')\n# after: clean the column in the source, or preprocess:\nimport re\nrows = [(d, re.sub(r'[^0-9.,()-]', '', a), c) for d, a, c in rows]","handlingStrategy":"try-catch","validationCode":"import re\nAMOUNT_OK = re.compile(r'^\\(?-?[0-9][0-9.,]*-?\\)?$')\nbad = [(i, r[amount_col]) for i, r in enumerate(rows, 2) if not AMOUNT_OK.match((r[amount_col] or '').strip())]","typeGuard":"def looks_like_amount(text: str) -> bool:\n    t = (text or '').strip().strip('()')\n    return bool(re.fullmatch(r'-?[0-9][0-9.,]*', t))","tryCatchPattern":"try:\n    load_cashflows(p)\nexcept CashFlowIngestError as e:\n    if 'is not usable' in str(e):\n        row = extract_row_number(e); log_defect(row, e); quarantine(p, row)","preventionTips":["Pre-clean amount cells: strip currency codes, symbols, NBSPs","Pin decimal_separator for grouped formats","Quarantine failing rows and alert rather than retrying unchanged"],"tags":["csv","number-parsing","value-error","cashflow"],"backgroundTag":"unparseable-numeric-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}