Page MenuHomePhabricator

TypeError: Session.request() got an unexpected keyword argument 'last_event_id'
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

A connection error is encountered from an event stream

What happens?:

When attempting to re-establish a connection a TypeError is raised.

WARNING: Connection error: fetch https://stream.wikimedia.org/v2/stream/mediawiki.page_change.v1 failed with wrong response status: 500.
Try to re-establish connection.
Traceback (most recent call last):
  File "/var/www/.venv/bin/copypatrol-backend", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/var/www/.venv/lib/python3.11/site-packages/copypatrol_backend/cli.py", line 268, in cli
    store_changes(since=parsed_args.since, total=parsed_args.total)
  File "/var/www/.venv/lib/python3.11/site-packages/copypatrol_backend/cli.py", line 25, in store_changes
    for event in change_stream(since=since, total=total):
  File "/var/www/.venv/lib/python3.11/site-packages/copypatrol_backend/stream_listener.py", line 49, in change_stream
    yield from stream
  File "<frozen _collections_abc>", line 330, in __next__
  File "/var/www/.venv/lib/python3.11/site-packages/pywikibot/tools/collections.py", line 278, in send
    return next(self._started_gen)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/.venv/lib/python3.11/site-packages/pywikibot/comms/eventstreams.py", line 379, in generator
    self.source.connect(config.max_retries)
  File "/var/www/.venv/lib/python3.11/site-packages/requests_sse/client.py", line 259, in connect
    response = self._session.request(
               ^^^^^^^^^^^^^^^^^^^^^^
TypeError: Session.request() got an unexpected keyword argument 'last_event_id'
CRITICAL: Exiting due to uncaught exception TypeError: Session.request() got an unexpected keyword argument 'last_event_id'

What should have happened instead?:

A TypeError is not raised by using latest_event_id instead of last_event_id because the keyword is used by requests_sse.EventSource.

Software version:

  • pywikibot: 10.0.0
  • requests-sse: 0.5.1

Event Timeline

JJMC89 changed the task status from Open to In Progress.May 17 2025, 6:38 AM
JJMC89 claimed this task.

Change #1147087 had a related patch set uploaded (by JJMC89; author: JJMC89):

[pywikibot/core@master] correct EventSource kwarg name from last_event_id to latest_event_id

https://gerrit.wikimedia.org/r/1147087

Change #1147087 merged by jenkins-bot:

[pywikibot/core@master] correct EventSource kwarg name from last_event_id to latest_event_id

https://gerrit.wikimedia.org/r/1147087

Xqt updated the task description. (Show Details)