{"record":{"id":"6dfa31aa938626a7","repo":"HKUDS/Vibe-Trading","slug":"model-name-must-be-a-finite-positive-number","errorCode":null,"errorMessage":"{model}: {name} must be a finite positive number, got {numeric}","messagePattern":"(.+?): (.+?) must be a finite positive number, got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/contracts.py","lineNumber":157,"sourceCode":"    \"\"\"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":139,"sourceCodeEnd":161,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/contracts.py#L139-L161","documentation":"After successful float coercion, require_positive rejects values that are zero, negative, NaN, or infinite. These are quantities (e.g. share counts, growth factors) where <=0 or non-finite is meaningless, so the model refuses rather than emitting nonsense output.","triggerScenarios":"Passing 0, -0.02, math.nan, or float('inf') to any parameter validated by require_positive — e.g. a negative discount rate or a NaN share count from an empty DataFrame aggregation.","commonSituations":"Sign errors (percentages supplied as -5 for a 5% decline); unit mistakes producing 0 after integer division; NaN from empty aggregations; inf from divide-by-zero upstream.","solutions":["Check the sign and finiteness of the value at its source; log the offending name/value.","Fix unit/sign conventions (e.g. pass 0.05 not -5, and 0.05 not 5 if a ratio is expected).","Guard: if not (math.isfinite(v) and v > 0): repair or raise before the call."],"exampleFix":"# before\nterminal_growth = math.nan\nrun_dcf(..., terminal_growth=terminal_growth)\n\n# after\nterminal_growth = 0.02\nassert math.isfinite(terminal_growth) and terminal_growth > 0","handlingStrategy":"validation","validationCode":"v = float(value)\nif not (math.isfinite(v) and v > 0):\n    raise ValueError(f'{name} must be finite positive, got {v}')","typeGuard":"def is_positive_finite(v):\n    return isinstance(v, (int, float)) and math.isfinite(v) and v > 0","tryCatchPattern":"except ValuationError as e:\n    if 'finite positive' in str(e):\n        log.error('fix sign/unit for %s', e); raise","preventionTips":["Check sign conventions for percentage/ratio inputs","Filter NaN from aggregations before model calls"],"tags":["valuation","positive-validation","nan","sign-error"],"backgroundTag":"value-out-of-range","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}