{"record":{"id":"b016f47f21669328","repo":"HKUDS/Vibe-Trading","slug":"model-name-max-circularity-iterations-must-be","errorCode":null,"errorMessage":"{MODEL_NAME}: max_circularity_iterations must be >= 1, got {max_circularity_iterations!r}","messagePattern":"(.+?): max_circularity_iterations must be >= 1, got (.+?)","errorType":"validation","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/threestatement.py","lineNumber":710,"sourceCode":"\n    Raises:\n        MissingInputError: If ``opening`` or ``drivers`` is missing a required\n            field.\n        ValuationError: If the driver sequences disagree in length, are empty,\n            if any opening or driver value is not a finite number, or if\n            ``circularity_tolerance`` / ``balance_tolerance`` /\n            ``max_circularity_iterations`` are not usable.\n        BalanceSheetError: If the opening balance sheet, or any projected\n            period's balance sheet, does not balance.\n        ConvergenceError: If any period's interest/revolver circularity fails\n            to converge within ``max_circularity_iterations``.\n    \"\"\"\n    require_inputs(opening, OPENING_REQUIRED_FIELDS, MODEL_NAME)\n    require_inputs(drivers, DRIVER_REQUIRED_FIELDS, MODEL_NAME)\n    circularity_tolerance = require_positive(circularity_tolerance, \"circularity_tolerance\", MODEL_NAME)\n    balance_tolerance = require_positive(balance_tolerance, \"balance_tolerance\", MODEL_NAME)\n    if max_circularity_iterations < 1:\n        raise ValuationError(\n            f\"{MODEL_NAME}: max_circularity_iterations must be >= 1, got \"\n            f\"{max_circularity_iterations!r}\"\n        )\n\n    for field in OPENING_REQUIRED_FIELDS:\n        _require_finite(opening[field], f\"opening {field}\", MODEL_NAME)\n    for field in DRIVER_REQUIRED_FIELDS:\n        for index, raw in enumerate(drivers[field]):\n            _require_finite(raw, f\"drivers {field}[{index}]\", MODEL_NAME)\n\n    periods = _resolve_period_count(drivers)\n\n    opening_balance_sheet = BalanceSheet(\n        period=0,\n        cash=float(opening[\"cash\"]),\n        net_working_capital=float(opening[\"net_working_capital\"]),\n        ppe=float(opening[\"ppe\"]),\n        revolver_balance=float(opening[\"revolver_balance\"]),","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/threestatement.py#L692-L728","documentation":"project_three_statement validates solver settings up front: max_circularity_iterations must be an integer >= 1. Zero or negative values (or a float like 0) raise ValuationError immediately, since the circularity loop would otherwise never execute.","triggerScenarios":"Passing max_circularity_iterations=0, a negative number, or a config default that was never set and defaulted to 0; also passing a float such as 50.0 can slip through only if comparisons hold, so integers < 1 are the real trigger.","commonSituations":"Config files where the knob is optional and omitted-then-zeroed; programmatic sweeps that include 0; disabling iterations intentionally but using the wrong API.","solutions":["Set max_circularity_iterations to at least 1 (practically 50-1000).","Fix the config default for the missing key.","Validate the setting before the call if it comes from user input."],"exampleFix":"# before\nproject_three_statement(opening, drivers, max_circularity_iterations=0)\n# after\nproject_three_statement(opening, drivers, max_circularity_iterations=100)","handlingStrategy":"validation","validationCode":"assert isinstance(max_circularity_iterations, int) and max_circularity_iterations >= 1","typeGuard":"def valid_iterations(n) -> bool:\n    return isinstance(n, int) and n >= 1","tryCatchPattern":"except ValuationError as e:\n    if 'max_circularity_iterations' in str(e): reset_to_default()","preventionTips":["Give config knobs explicit safe defaults","Validate solver settings alongside financial inputs"],"tags":["valuation","three-statement","invalid-argument","config"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}