{"record":{"id":"759709a037b04eda","repo":"python-telegram-bot/python-telegram-bot","slug":"current-offset-and-auto-pagination-are-mutually-ex","errorCode":null,"errorMessage":"current_offset and auto_pagination are mutually exclusive!","messagePattern":"current_offset and auto_pagination are mutually exclusive!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/telegram/_inline/inlinequery.py","lineNumber":179,"sourceCode":"        For the documentation of the arguments, please see\n        :meth:`telegram.Bot.answer_inline_query`.\n\n        .. versionchanged:: 20.0\n            Raises :class:`ValueError` instead of :class:`TypeError`.\n\n        Keyword Args:\n            auto_pagination (:obj:`bool`, optional): If set to :obj:`True`, :attr:`offset` will be\n                passed as\n                :paramref:`current_offset <telegram.Bot.answer_inline_query.current_offset>` to\n                :meth:`telegram.Bot.answer_inline_query`.\n                Defaults to :obj:`False`.\n\n        Raises:\n            ValueError: If both :paramref:`~telegram.Bot.answer_inline_query.current_offset` and\n                :paramref:`auto_pagination` are supplied.\n        \"\"\"\n        if current_offset and auto_pagination:\n            raise ValueError(\"current_offset and auto_pagination are mutually exclusive!\")\n        return await self.get_bot().answer_inline_query(\n            inline_query_id=self.id,\n            current_offset=self.offset if auto_pagination else current_offset,\n            results=results,\n            cache_time=cache_time,\n            is_personal=is_personal,\n            next_offset=next_offset,\n            button=button,\n            read_timeout=read_timeout,\n            write_timeout=write_timeout,\n            connect_timeout=connect_timeout,\n            pool_timeout=pool_timeout,\n            api_kwargs=api_kwargs,\n        )\n\n    MAX_RESULTS: Final[int] = constants.InlineQueryLimit.RESULTS\n    \"\"\":const:`telegram.constants.InlineQueryLimit.RESULTS`\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/python-telegram-bot/python-telegram-bot/blob/d3b69d2e9fb7af6c796f84516cfda751752c7cb7/src/telegram/_inline/inlinequery.py#L161-L197","documentation":"InlineQuery.answer raises ValueError when both `current_offset` and `auto_pagination` are supplied. auto_pagination derives the offset automatically from self.offset, so an explicit current_offset would conflict. Only one pagination strategy may be active per answer call.","triggerScenarios":"Calling inline_query.answer(results, current_offset='50', auto_pagination=True); enabling auto_pagination in a handler that already tracks and forwards the offset manually.","commonSituations":"Migrating manual offset bookkeeping to auto_pagination without removing the old current_offset plumbing; copy-pasted pagination examples combined with the auto flag.","solutions":["Drop current_offset and let auto_pagination handle it","Or keep manual pagination and remove auto_pagination=True","Pick one pagination strategy per handler and delete the other's code path"],"exampleFix":"# before\ninline_query.answer(results, current_offset=inline_query.offset, auto_pagination=True)\n\n# after\ninline_query.answer(results, auto_pagination=True)","handlingStrategy":"validation","validationCode":"if current_offset and auto_pagination:\n    raise ValueError('pick one pagination strategy')\nawait inline_query.answer(results, current_offset=current_offset, auto_pagination=False)","typeGuard":null,"tryCatchPattern":"try:\n    await inline_query.answer(results, auto_pagination=True)\nexcept ValueError:\n    await inline_query.answer(results, current_offset=inline_query.offset)","preventionTips":["Choose one pagination strategy per handler","Prefer auto_pagination for new code"],"tags":["python","python-telegram-bot","inline-query","pagination","mutually-exclusive"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"d3b69d2e9fb7af6c796f84516cfda751752c7cb7","analyzedAt":"2026-08-28T16:18:54.805Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}