{"record":{"id":"1b95c3e304040f58","repo":"HKUDS/Vibe-Trading","slug":"model-name-must-be-a-number-got-value-r-1b95c3","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/dcf.py","lineNumber":245,"sourceCode":"    \"\"\"Check a value that is a signed formula's magnitude, so must be >= 0.\n\n    Args:\n        value: The candidate magnitude.\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 negative or not a finite number. A\n            negative magnitude here would silently flip the sign the bridge\n            formula already applies.\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 math.isfinite(numeric) or numeric < 0.0:\n        raise ValuationError(\n            f\"{model}: {name} must be supplied as a non-negative magnitude \"\n            f\"(its sign is applied by the bridge formula), got {numeric!r}\"\n        )\n    return numeric\n\n\ndef _require_finite(value: float, name: str, model: str) -> float:\n    \"\"\"Check a value is a finite number, refusing NaN and infinity.\n\n    Args:\n        value: The candidate value.\n        name: Field name for the error message.\n        model: Model name for the error message.\n\n    Returns:\n        ``value`` as a float.","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/dcf.py#L227-L263","documentation":"_require_nonnegative coerces then rejects values that fail float() (strings like '5%', None) with 'must be a number'. It guards bridge/sign-sensitive magnitudes (used by wacc, equity_bridge, sensitivity_grid) where the caller supplies a magnitude and the formula applies the sign.","triggerScenarios":"Calling wacc/equity_bridge/sensitivity_grid with a non-numeric magnitude, e.g. a spread of None or '1.5%' instead of 0.015.","commonSituations":"Config values as formatted strings; optional parameters left as None by a partial-config loader; Excel imports with text cells.","solutions":["Parse/convert to float upstream; strip '%' and divide by 100 where applicable.","Default optional magnitudes to 0.0 when genuinely absent rather than None.","Validate config types at load time so strings never reach the model."],"exampleFix":"# before\nwacc(..., debt_beta='0.15')\n\n# after\nwacc(..., debt_beta=0.15)","handlingStrategy":"type-guard","validationCode":"try:\n    magnitude = float(value)\nexcept (TypeError, ValueError):\n    raise ValueError(f'expected numeric magnitude, 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        magnitude = parse_percent_string(value)","preventionTips":["Convert '1.5%' style config values to 0.015 upstream","Default absent magnitudes to 0.0, not None"],"tags":["valuation","type-error","parsing","wacc"],"backgroundTag":"type-conversion-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}