{"record":{"id":"2139eaab231e72b5","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"max-results-must-be-between-1-and-100","errorCode":null,"errorMessage":"max_results must be between 1 and 100","messagePattern":"max_results must be between 1 and 100","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/research_web.py","lineNumber":83,"sourceCode":"        valid_engines = {\"duckduckgo\", \"bing\", \"searxng\", \"serper\"}\n        if v.lower() not in valid_engines:\n            raise ValueError(\n                f\"Search engine must be one of: {', '.join(valid_engines)}\"\n            )\n        return v.lower()\n\n    @validator(\"query\")\n    def validate_query(cls, v):\n        \"\"\"Validate search query.\"\"\"\n        if not v or not isinstance(v, str):\n            raise ValueError(\"Query must be a non-empty string\")\n        return v\n\n    @validator(\"max_results\")\n    def validate_max_results(cls, v):\n        \"\"\"Validate max results.\"\"\"\n        if v < 1 or v > 100:\n            raise ValueError(\"max_results must be between 1 and 100\")\n        return v\n\n\n# Define advanced PDF detection regex\nPDF_REGEX = re.compile(r\"\\.pdf(#.*)?(\\?.*)?$\", re.IGNORECASE)\n\n\n# Rate limiting decorator\ndef rate_limited(calls: int, period: int = 60):\n    \"\"\"\n    Decorator to limit the rate of function calls.\n\n    Args:\n        calls (int): Maximum number of calls allowed in the period.\n        period (int): Time period in seconds.\n\n    Returns:\n        Callable: Decorated function with rate limiting.","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/research_web.py#L65-L101","documentation":"ValueError from the pydantic validator on max_results in research_web: the number of search results per query must be between 1 and 100 inclusive.","triggerScenarios":"Setting max_results=0, a negative number, or >100 on the web search parameters model.","commonSituations":"Copying configs from tools that allow unlimited results; setting a very high count to 'get everything' which the backend rejects.","solutions":["Clamp max_results to 1..100, e.g. min(100, max(1, n))","Pick a realistic value like 10-20 per query","Paginate queries if more coverage is needed"],"exampleFix":"# before\nparams = {\"query\": q, \"max_results\": 500}\n# after\nparams = {\"query\": q, \"max_results\": min(500, 100)}","handlingStrategy":"validation","validationCode":"max_results = min(100, max(1, int(max_results)))","typeGuard":"def is_valid_max_results(n) -> bool:\n    return isinstance(n, int) and not isinstance(n, bool) and 1 <= n <= 100","tryCatchPattern":null,"preventionTips":["Clamp user-supplied result counts to 1..100","Paginate additional queries instead of huge max_results","Validate numeric config ranges at load time"],"tags":["validation","search","pagination"],"backgroundTag":"argument-out-of-range","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}