{"record":{"id":"e0706db90c292abb","repo":"HKUDS/Vibe-Trading","slug":"comps-name-must-be-a-finite-number-got-value","errorCode":null,"errorMessage":"comps: {name} must be a finite number, got {value!r}","messagePattern":"comps: (.+?) must be a finite number, got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/comps.py","lineNumber":405,"sourceCode":"    if not math.isfinite(total_debt):\n        raise ValuationError(\n            f\"comps: total_debt must be a finite number, got {total_debt!r}\"\n        )\n    if not math.isfinite(cash_and_equivalents):\n        raise ValuationError(\n            f\"comps: cash_and_equivalents must be a finite number, got {cash_and_equivalents!r}\"\n        )\n    total = total_debt - cash_and_equivalents\n    for name, value in (\n        (\"minority_interest\", minority_interest),\n        (\"preferred_stock\", preferred_stock),\n        (\"investments_in_associates\", investments_in_associates),\n    ):\n        if value is None:\n            omitted.append(name)\n            continue\n        if not math.isfinite(value):\n            raise ValuationError(\n                f\"comps: {name} must be a finite number, got {value!r}\"\n            )\n        sign = -1.0 if name == \"investments_in_associates\" else 1.0\n        total += sign * value\n    return total, tuple(omitted)\n\n\ndef enterprise_value(\n    *,\n    market_cap: float,\n    total_debt: float,\n    cash_and_equivalents: float,\n    minority_interest: float | None = None,\n    preferred_stock: float | None = None,\n    investments_in_associates: float | None = None,\n) -> EVBridgeResult:\n    \"\"\"Bridge a known equity market value to enterprise value.\n","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/comps.py#L387-L423","documentation":"Optional EV-bridge components (minority_interest, preferred_stock, investments_in_associates) may be None (and are then reported as omitted), but if supplied they must be finite numbers. Supplying NaN/inf for one of them fails here so the bridge total cannot be corrupted.","triggerScenarios":"Passing minority_interest=float('nan') (etc.) to enterprise_value or equity_value_from_enterprise_value instead of leaving it None or giving a finite value.","commonSituations":"Uniformly filling optional fields from a dict of extracted financials where some values are NaN, instead of mapping NaN -> None.","solutions":["Map missing optional components to None rather than NaN before calling the bridge.","If you have a sourced value, ensure it is a plain finite float.","Sanitize: {k: (v if v is not None and math.isfinite(v) else None) for k, v in components.items()}."],"exampleFix":"# before\nminority_interest = row['minority_interest']  # NaN\n\n# after\nminority_interest = row['minority_interest'] if row['minority_interest'] is not None and math.isfinite(row['minority_interest']) else None","handlingStrategy":"type-guard","validationCode":"components = {k: (v if v is not None and math.isfinite(v) else None)\n               for k, v in raw_components.items()}","typeGuard":"def finite_or_none(v):\n    return None if v is None else (float(v) if math.isfinite(v) else None)","tryCatchPattern":"except ValuationError as e:\n    if 'must be a finite number' in str(e):\n        # fall back to omitting the component\n        ev = enterprise_value(market_cap, total_debt, cash, minority_interest=None)","preventionTips":["Never pass NaN for optional bridge components; use None","Centralize the NaN->None normalization in one helper"],"tags":["valuation","ev-bridge","optional-fields","nan"],"backgroundTag":"nan-input-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}