python-telegram-bot/python-telegram-bot · error · ValueError
current_offset and auto_pagination are mutually exclusive!
Error message
current_offset and auto_pagination are mutually exclusive!
What it means
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.
Source
Thrown at src/telegram/_inline/inlinequery.py:179
For the documentation of the arguments, please see
:meth:`telegram.Bot.answer_inline_query`.
.. versionchanged:: 20.0
Raises :class:`ValueError` instead of :class:`TypeError`.
Keyword Args:
auto_pagination (:obj:`bool`, optional): If set to :obj:`True`, :attr:`offset` will be
passed as
:paramref:`current_offset <telegram.Bot.answer_inline_query.current_offset>` to
:meth:`telegram.Bot.answer_inline_query`.
Defaults to :obj:`False`.
Raises:
ValueError: If both :paramref:`~telegram.Bot.answer_inline_query.current_offset` and
:paramref:`auto_pagination` are supplied.
"""
if current_offset and auto_pagination:
raise ValueError("current_offset and auto_pagination are mutually exclusive!")
return await self.get_bot().answer_inline_query(
inline_query_id=self.id,
current_offset=self.offset if auto_pagination else current_offset,
results=results,
cache_time=cache_time,
is_personal=is_personal,
next_offset=next_offset,
button=button,
read_timeout=read_timeout,
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
)
MAX_RESULTS: Final[int] = constants.InlineQueryLimit.RESULTS
""":const:`telegram.constants.InlineQueryLimit.RESULTS`
View on GitHub (pinned to d3b69d2e9f)
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
Example fix
# before inline_query.answer(results, current_offset=inline_query.offset, auto_pagination=True) # after inline_query.answer(results, auto_pagination=True)
Defensive patterns
Strategy: validation
Validate before calling
if current_offset and auto_pagination:
raise ValueError('pick one pagination strategy')
await inline_query.answer(results, current_offset=current_offset, auto_pagination=False) Try / catch
try:
await inline_query.answer(results, auto_pagination=True)
except ValueError:
await inline_query.answer(results, current_offset=inline_query.offset) Prevention
- Choose one pagination strategy per handler
- Prefer auto_pagination for new code
When it happens
Trigger: 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.
Common situations: Migrating manual offset bookkeeping to auto_pagination without removing the old current_offset plumbing; copy-pasted pagination examples combined with the auto flag.
Related errors
- `current_offset` and `next_offset` are mutually exclusive!
- `allow_sending_without_reply` and `reply_parameters` are mut
- `reply_to_message_id` and `reply_parameters` are mutually ex
- `allow_sending_without_reply` and `dict`-value input for `do
- This Game has no 'text'.
AI-assisted analysis of python-telegram-bot/python-telegram-bot@d3b69d2e9f (2026-08-28).
Data as JSON: /api/errors/759709a037b04eda.
Report an issue: GitHub.