{"record":{"id":"e88bc97fea35baea","repo":"microsoft/semantic-kernel","slug":"offset-must-be-less-than-10","errorCode":null,"errorMessage":"offset must be less than 10.","messagePattern":"offset must be less than 10\\.","errorType":"exception","errorClass":"ServiceInvalidRequestError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/brave.py","lineNumber":252,"sourceCode":"            logger.error(f\"Failed to get search results: {ex}\")\n            raise ServiceInvalidRequestError(\"Failed to get search results.\") from ex\n        except RequestError as ex:\n            logger.error(f\"Client error occurred: {ex}\")\n            raise ServiceInvalidRequestError(\"A client error occurred while getting search results.\") from ex\n        except Exception as ex:\n            logger.error(f\"An unexpected error occurred: {ex}\")\n            raise ServiceInvalidRequestError(\"An unexpected error occurred while getting search results.\") from ex\n\n    def _validate_options(self, options: SearchOptions) -> None:\n        if options.top <= 0:\n            raise ServiceInvalidRequestError(\"count value must be greater than 0.\")\n        if options.top >= 21:\n            raise ServiceInvalidRequestError(\"count value must be less than 21.\")\n\n        if options.skip < 0:\n            raise ServiceInvalidRequestError(\"offset must be greater than or equal to 0.\")\n        if options.skip > 9:\n            raise ServiceInvalidRequestError(\"offset must be less than 10.\")\n\n    def _get_url(self) -> str:\n        return DEFAULT_URL\n\n    def _parse_filter_lambda(self, filter_lambda: Callable | str) -> list[dict[str, str]]:\n        \"\"\"Parse a string lambda or string expression into a list of {field: value} dicts using AST.\"\"\"\n        expr = filter_lambda if isinstance(filter_lambda, str) else getsource(filter_lambda).strip()\n        tree = ast.parse(expr, mode=\"eval\")\n        node = tree.body\n        visitor = SearchLambdaVisitor(valid_parameters=QUERY_PARAMETERS)\n        visitor.visit(node)\n        return visitor.filters\n\n    def _build_request_parameters(self, query: str, options: SearchOptions) -> dict[str, str | int | bool]:\n        params: dict[str, str | int] = {\"q\": query or \"\", \"count\": options.top, \"offset\": options.skip}\n        if not options.filter:\n            return params\n        filters = options.filter","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/brave.py#L234-L270","documentation":"Brave caps the offset at 9 (so skip + top stays within the API's result-depth limit); the connector enforces skip <= 9 client-side and raises ServiceInvalidRequestError for skip > 9. This reflects Brave's deep-pagination limit, not an arbitrary connector choice.","triggerScenarios":"Calling search() with skip > 9, e.g. skip=10 or higher to reach page 3+. The check at brave.py:252-253 fires in _validate_options.","commonSituations":"Attempting deep pagination beyond what Brave returns; computing skip as page_number * page_size and exceeding 9.","solutions":["Keep skip within [0, 9]; combine with top <= 20 to stay within Brave's max result depth (skip + top <= ~10 offset).","For deeper result sets, narrow the query or accept Brave's pagination ceiling rather than increasing offset.","Clamp computed offsets to 9 before calling search."],"exampleFix":"// before\nresults = await connector.search(query, skip=20)\n// after\nresults = await connector.search(query, skip=min(9, computed_offset))\n","handlingStrategy":"validation","validationCode":"if skip > 9:\n    raise ValueError(\"Brave caps offset at 9\")\nresults = await connector.search(query, skip=min(9, skip))","typeGuard":"def is_valid_skip(skip: int) -> bool:\n    return isinstance(skip, int) and 0 <= skip <= 9","tryCatchPattern":null,"preventionTips":["Keep skip within [0, 9]; do not attempt deep pagination beyond Brave's limit.","Clamp computed offsets to 9; narrow the query to reach earlier-ranked results."],"tags":["brave","validation","input","pagination"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}