Page MenuHomePhabricator

[ErinnerMichBot] Script stops with error when date parameter contains blanks
Closed, ResolvedPublicBUG REPORT

Description

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

Add a blank before the date, e.g. {{ErinnerMich| 05.04.2026}}

(as happened here: https://de.wikipedia.org/w/index.php?title=Benutzerin_Diskussion:Itti&diff=prev&oldid=255234971 )

What happens?:

Traceback (most recent call last):
  File "/data/project/erinnermich/production/receive_requests.py", line 3, in <module>
    receiver.run_bot()
  File "/data/project/erinnermich/production/erinnermichbot/receiver.py", line 59, in run_bot
    self.process_notifications(notifications)
  File "/data/project/erinnermich/production/erinnermichbot/receiver.py", line 214, in process_notifications
    self.get_date_bytext(obj)
  File "/data/project/erinnermich/production/erinnermichbot/receiver.py", line 143, in get_date_bytext
    obj.set_date(dates[0].strftime('%d.%m.%Y'))
                 ~~~~~^^^
IndexError: list index out of range

What should have happened instead?:

Date parameter should be trimmed before parsing. And even with blanks in between or completely unreadable dates the script should react (let the user know the date was not readable) and not stop with an error.

(No time to take care of that right now, so just documenting it for later)

Event Timeline

M-J claimed this task.

@Tkarcher thanks for https://gitlab.wikimedia.org/toolforge-repos/erinnermich/-/commit/519912861d313770c31d11cd7169b048ee81458f - I reviewed this and added a specific test for this case (https://gitlab.wikimedia.org/toolforge-repos/erinnermich/-/commit/55998d8df0b4f87f31eda1752aa41126f2b7d0af). All other tests are successfull with your changes, so I merged this into produktion. the fix is live