{"record":{"id":"72667494258a1656","repo":"HKUDS/Vibe-Trading","slug":"model-name-must-be-a-number-got-value-r","errorCode":null,"errorMessage":"{model}: {name} must be a number, got {value!r}","messagePattern":"(.+?): (.+?) must be a number, got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/contracts.py","lineNumber":155,"sourceCode":"\ndef require_positive(value: float, name: str, model: str) -> float:\n    \"\"\"Check a value that is meaningless at or below zero.\n\n    Args:\n        value: The value to check, e.g. a share count or a discount rate.\n        name: Field name for the error message.\n        model: Model name for the error message.\n\n    Returns:\n        ``value`` as a float.\n\n    Raises:\n        ValuationError: If the value is not a finite number greater than zero.\n    \"\"\"\n    try:\n        numeric = float(value)\n    except (TypeError, ValueError) as exc:\n        raise ValuationError(f\"{model}: {name} must be a number, got {value!r}\") from exc\n    if not numeric > 0.0 or numeric != numeric or numeric in (float(\"inf\"), float(\"-inf\")):\n        raise ValuationError(\n            f\"{model}: {name} must be a finite positive number, got {numeric}\"\n        )\n    return numeric\n","sourceCodeStart":137,"sourceCodeEnd":161,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/contracts.py#L137-L161","documentation":"require_positive first coerces the value with float(); if that raises TypeError/ValueError (non-numeric input like a string or None), it raises this 'must be a number' ValuationError. Used for values meaningless at/below zero (growth rates, share counts, etc.) in __post_init__, equity_bridge, sensitivity_grid, project_three_statement.","triggerScenarios":"Passing '5%', None, a dict, or an unparseable string where a positive float is required, e.g. a shares figure of 'n/a'.","commonSituations":"Config values left as strings ('0.05' parses, '5%' does not); Excel/CSV cells with text like 'n/a'; None defaults leaking into required parameters.","solutions":["Convert to float explicitly at your boundary and fail with your own clearer message.","Strip '%' and other decorations before parsing if your config uses formatted numbers.","Use typed config (pydantic/dataclass with float fields) so strings never reach the library."],"exampleFix":"# before\nshares = row['shares']  # '1.2B'\n\n# after\nshares = parse_shares(row['shares'])  # returns 1_200_000_000.0, raises on 'n/a'","handlingStrategy":"type-guard","validationCode":"try:\n    value = float(value)\nexcept (TypeError, ValueError):\n    raise ValueError(f'expected a number, got {value!r}')","typeGuard":"def is_numeric(v):\n    return isinstance(v, (int, float)) and not isinstance(v, bool)","tryCatchPattern":"except ValuationError as e:\n    if 'must be a number' in str(e):\n        value = parse_formatted(row[name])  # your parser","preventionTips":["Parse formatted strings ('5%') at the config boundary","Use typed config objects so strings never reach model APIs"],"tags":["valuation","type-error","parsing","validation"],"backgroundTag":"type-conversion-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}