{"record":{"id":"f3ee0bc3e42b82d1","repo":"HKUDS/Vibe-Trading","slug":"field-must-be-a-positive-integer-got-value-r","errorCode":null,"errorMessage":"{field} must be a positive integer, got {value!r}","messagePattern":"(.+?) must be a positive integer, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/qveris_tool.py","lineNumber":376,"sourceCode":"    Args:\n        value: Raw argument value; ``None`` and ``\"\"`` mean \"not supplied\".\n        field: Argument name, used in the error message.\n        default: Value to use when the argument was not supplied.\n\n    Returns:\n        The requested integer, or ``default`` when the argument was absent.\n\n    Raises:\n        ValueError: If the value is present but not a finite positive integer.\n            QVeris calls are billable, so an explicitly malformed option is\n            rejected instead of being replaced by a default.\n    \"\"\"\n    if value is None or value == \"\":\n        return default\n    try:\n        number = float(value)\n    except (TypeError, ValueError, OverflowError):\n        raise ValueError(f\"{field} must be a positive integer, got {value!r}\") from None\n    if not math.isfinite(number) or number != int(number) or int(number) < 1:\n        raise ValueError(f\"{field} must be a positive integer, got {value!r}\")\n    return int(number)\n\n\nclass _QVerisBaseTool(BaseTool):\n    \"\"\"Shared availability and client helpers for QVeris tools.\"\"\"\n\n    @classmethod\n    def check_available(cls) -> bool:\n        \"\"\"Hide QVeris tools until explicitly enabled and keyed.\"\"\"\n        return is_qveris_configured()\n\n    def _client(self) -> QVerisClient:\n        return QVerisClient()\n\n\nclass QVerisSearchTool(_QVerisBaseTool):","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/qveris_tool.py#L358-L394","documentation":"Raised by qveris_tool._positive_int when an optional numeric parameter cannot be interpreted as a positive integer: the value fails float() conversion (TypeError/ValueError/OverflowError), is non-finite (NaN/inf), is not a whole number, or is < 1. Note that None and empty string are allowed and return the default, so only genuinely present-but-invalid values raise.","triggerScenarios":"Passing limit='abc' or limit=None-like strings such as 'null'/'nan' (float('nan') parses but fails isfinite); limit=2.5 (not whole); limit=0 or negative; limit=float('inf') via 'inf'; passing a dict/list that float() rejects with TypeError.","commonSituations":"LLM tool calls emitting stringified booleans or nulls ('true', 'null'); users passing decimal page sizes; config defaults of 0 meaning 'unlimited' but the tool requires >=1; untrusted numeric input from spreadsheets.","solutions":["Pass a whole number >= 1 (or its string form like '50'), or omit/empty the parameter to use the default","Coerce or validate numeric inputs before calling: check isdigit/whole-value and range","Map 'unlimited' intents to a large explicit integer instead of 0","Reject placeholder strings like 'null'/'nan'/'inf' in upstream input parsing"],"exampleFix":"# before\nlimit=0\n\n# after\nlimit=100  # or omit limit to use the tool default","handlingStrategy":"validation","validationCode":"def to_positive_int(value, field: str, default: int | None = None):\n    if value is None or value == \"\":\n        return default\n    try:\n        n = float(value)\n    except (TypeError, ValueError, OverflowError):\n        raise ValueError(f\"{field} must be a positive integer, got {value!r}\")\n    if not math.isfinite(n) or n != int(n) or int(n) < 1:\n        raise ValueError(f\"{field} must be a positive integer, got {value!r}\")\n    return int(n)\n\nlimit = to_positive_int(raw_limit, \"limit\", default=25)","typeGuard":"def is_positive_int_value(v: object) -> bool:\n    if isinstance(v, bool) or not isinstance(v, (int, float, str)):\n        return False\n    try:\n        n = float(v)\n    except (TypeError, ValueError, OverflowError):\n        return False\n    return math.isfinite(n) and n == int(n) and int(n) >= 1","tryCatchPattern":"try:\n    result = tool.execute(limit=raw_limit, ...)\nexcept ValueError as e:\n    if \"positive integer\" in str(e):\n        result = tool.execute(limit=None, ...)  # fall back to default and warn user","preventionTips":["Coerce numeric query params with int()/float() plus range checks at the API boundary","Reject placeholder strings ('null', 'nan', 'inf', 'true') during input sanitization","Use omission or '' for 'use default' instead of 0 or -1 sentinels"],"tags":["qveris","validation","positive-integer","input-validation"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}