{"record":{"id":"0dd183ccd9d6bacc","repo":"HKUDS/Vibe-Trading","slug":"kind-is-required-and-cannot-be-empty","errorCode":null,"errorMessage":"kind is required and cannot be empty","messagePattern":"kind is required and cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":117,"sourceCode":"    actually bites on those files instead of silently treating each spelling as\n    an unconstrained custom kind.\n\n    Args:\n        value: Raw kind label from a caller or a file.\n\n    Returns:\n        Lower-cased label with spaces and hyphens collapsed to underscores.\n\n    Raises:\n        ValueError: If the label is not a string or is blank.\n    \"\"\"\n    if not isinstance(value, str):\n        raise ValueError(f\"kind must be a string, got {type(value).__name__}\")\n    cleaned = value.strip().lower().replace(\"-\", \"_\").replace(\" \", \"_\")\n    while \"__\" in cleaned:\n        cleaned = cleaned.replace(\"__\", \"_\")\n    if not cleaned:\n        raise ValueError(\"kind is required and cannot be empty\")\n    return cleaned\n\n\n@dataclass(frozen=True)\nclass CashFlow:\n    \"\"\"A single dated cash amount in one currency.\n\n    Attributes:\n        date: Settlement date. ``datetime`` and ISO-8601 strings are accepted\n            and normalized to ``datetime.date``.\n        amount: Signed amount, positive into the holder. See the module\n            docstring for the convention and its enforcement.\n        kind: Canonical kind label, e.g. ``\"capital_call\"`` or ``\"coupon\"``.\n            Normalized via ``normalize_kind``.\n        currency: Required currency code, normalized to uppercase.\n        metadata: Free-form extra fields, exposed as a read-only mapping so the\n            flow stays immutable. Ingestion puts unmapped file columns here\n            rather than discarding them.","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L99-L135","documentation":"Raised by CashFlow normalize_kind when, after stripping and normalizing, the label is empty — the input was blank, only separators ('-', ' ', '_'), or became empty after collapse. kind is a required discriminator for cash-flow categorization, so blank values are rejected.","triggerScenarios":"normalize_kind(''), normalize_kind('   '), normalize_kind('---') or '__' — all reduce to an empty string after cleaning.","commonSituations":"Empty spreadsheet cells or CSV columns parsed as ''; forms submitted with whitespace-only labels; default '' placeholders in data pipelines.","solutions":["Supply a meaningful label, e.g. 'dividend' or 'wire_in'.","Skip or filter out rows with blank kind before constructing cash-flow entities.","Map blank incoming labels to an explicit 'unknown' category if you must ingest them."],"exampleFix":"# before\nnormalize_kind('  ')\n\n# after\nnormalize_kind('wire_in')","handlingStrategy":"validation","validationCode":"def kind_nonblank(value: str) -> bool:\n    import re\n    return bool(re.sub(r'[_\\s-]+', '', str(value or '')))","typeGuard":"def is_valid_kind(value) -> bool:\n    return isinstance(value, str) and bool(value.strip()) and bool(value.strip().replace('_', '').replace('-', ''))","tryCatchPattern":null,"preventionTips":["Skip or quarantine rows with blank kind during ingestion","Use explicit sentinel labels like 'unknown' instead of empty strings"],"tags":["cashflow","validation","entities","empty-value"],"backgroundTag":"empty-required-field","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}