La commande stats fait planter le bot #9

Closed
opened 2024-07-12 18:40:49 +02:00 by fcouchet · 4 comments

L'utilisation de la commande !stats fait planter le bot.

Dans les logs (fichier /var/log/hebdobot/hebdobot.log il y a


2024-07-12 18:36:06.332 - FROM SERVER: :madix!~madix@april/staff/madix PRIVMSG #april-test :!stats
2024-07-12 18:36:06.333 - _dispatcher: all_raw_messages
2024-07-12 18:36:06.333 - command: pubmsg, source: madix!~madix@april/staff/madix, target: #april-test, arguments: ['!stats'], tags: None
2024-07-12 18:36:06.333 - _dispatcher: pubmsg
2024-07-12 18:36:06.333 - INFO - !stats caught.
L'utilisation de la commande !stats fait planter le bot. Dans les logs (fichier /var/log/hebdobot/hebdobot.log il y a ``` 2024-07-12 18:36:06.332 - FROM SERVER: :madix!~madix@april/staff/madix PRIVMSG #april-test :!stats 2024-07-12 18:36:06.333 - _dispatcher: all_raw_messages 2024-07-12 18:36:06.333 - command: pubmsg, source: madix!~madix@april/staff/madix, target: #april-test, arguments: ['!stats'], tags: None 2024-07-12 18:36:06.333 - _dispatcher: pubmsg 2024-07-12 18:36:06.333 - INFO - !stats caught. ```

La version au moment de l'erreur: c4a3e78967.

Jul 12 18:31:57 bots systemd[1]: Started hebdobot-v3.service - "Hebdobot v3 en python".
Jul 12 18:36:06 bots python3[3565258]: Traceback (most recent call last):
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/src/hebdobot.py", line 91, in <module>
Jul 12 18:36:06 bots python3[3565258]:     HebdoBot(settings).start()
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/bot.py", line 348, in start
Jul 12 18:36:06 bots python3[3565258]:     super().start()
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 1272, in start
Jul 12 18:36:06 bots python3[3565258]:     self.reactor.process_forever()
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 916, in process_forever
Jul 12 18:36:06 bots python3[3565258]:     consume(repeatfunc(one))
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/more_itertools/recipes.py", line 184, in consume
Jul 12 18:36:06 bots python3[3565258]:     deque(iterator, maxlen=0)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 897, in process_once
Jul 12 18:36:06 bots python3[3565258]:     self.process_data(in_)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 862, in process_data
Jul 12 18:36:06 bots python3[3565258]:     conn.process_data()
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 338, in process_data
Jul 12 18:36:06 bots python3[3565258]:     self._process_line(line)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 369, in _process_line
Jul 12 18:36:06 bots python3[3565258]:     handler(arguments, command, source, tags)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 413, in _handle_message
Jul 12 18:36:06 bots python3[3565258]:     self._handle_event(event)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 446, in _handle_event
Jul 12 18:36:06 bots python3[3565258]:     self.reactor._handle_event(self, event)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 992, in _handle_event
Jul 12 18:36:06 bots python3[3565258]:     result = handler.callback(connection, event)
Jul 12 18:36:06 bots python3[3565258]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 1229, in _dispatcher
Jul 12 18:36:06 bots python3[3565258]:     method(connection, event)
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/src/hebdobot.py", line 73, in on_pubmsg
Jul 12 18:36:06 bots python3[3565258]:     if hook.process(self, channel, sender, message):
Jul 12 18:36:06 bots python3[3565258]:        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/src/hooks/stats.py", line 18, in process
Jul 12 18:36:06 bots python3[3565258]:     stats.load()
Jul 12 18:36:06 bots systemd[1]: hebdobot-v3.service: Main process exited, code=exited, status=1/FAILURE
Jul 12 18:36:06 bots python3[3565258]:   File "/srv/hebdobot-py/src/review/stats.py", line 165, in load
Jul 12 18:36:06 bots python3[3565258]:     int(datas[2]) if datas[2]!="" else None,
Jul 12 18:36:06 bots python3[3565258]:     ^^^^^^^^^^^^^
Jul 12 18:36:06 bots python3[3565258]: ValueError: invalid literal for int() with base 10: 'None'
Jul 12 18:36:06 bots systemd[1]: hebdobot-v3.service: Failed with result 'exit-code'.
La version au moment de l'erreur: c4a3e7896779720b9c7e55bd7553817ff4896b81. ``` Jul 12 18:31:57 bots systemd[1]: Started hebdobot-v3.service - "Hebdobot v3 en python". Jul 12 18:36:06 bots python3[3565258]: Traceback (most recent call last): Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/src/hebdobot.py", line 91, in <module> Jul 12 18:36:06 bots python3[3565258]: HebdoBot(settings).start() Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/bot.py", line 348, in start Jul 12 18:36:06 bots python3[3565258]: super().start() Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 1272, in start Jul 12 18:36:06 bots python3[3565258]: self.reactor.process_forever() Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 916, in process_forever Jul 12 18:36:06 bots python3[3565258]: consume(repeatfunc(one)) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/more_itertools/recipes.py", line 184, in consume Jul 12 18:36:06 bots python3[3565258]: deque(iterator, maxlen=0) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 897, in process_once Jul 12 18:36:06 bots python3[3565258]: self.process_data(in_) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 862, in process_data Jul 12 18:36:06 bots python3[3565258]: conn.process_data() Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 338, in process_data Jul 12 18:36:06 bots python3[3565258]: self._process_line(line) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 369, in _process_line Jul 12 18:36:06 bots python3[3565258]: handler(arguments, command, source, tags) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 413, in _handle_message Jul 12 18:36:06 bots python3[3565258]: self._handle_event(event) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 446, in _handle_event Jul 12 18:36:06 bots python3[3565258]: self.reactor._handle_event(self, event) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 992, in _handle_event Jul 12 18:36:06 bots python3[3565258]: result = handler.callback(connection, event) Jul 12 18:36:06 bots python3[3565258]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/venv/lib/python3.11/site-packages/irc/client.py", line 1229, in _dispatcher Jul 12 18:36:06 bots python3[3565258]: method(connection, event) Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/src/hebdobot.py", line 73, in on_pubmsg Jul 12 18:36:06 bots python3[3565258]: if hook.process(self, channel, sender, message): Jul 12 18:36:06 bots python3[3565258]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/src/hooks/stats.py", line 18, in process Jul 12 18:36:06 bots python3[3565258]: stats.load() Jul 12 18:36:06 bots systemd[1]: hebdobot-v3.service: Main process exited, code=exited, status=1/FAILURE Jul 12 18:36:06 bots python3[3565258]: File "/srv/hebdobot-py/src/review/stats.py", line 165, in load Jul 12 18:36:06 bots python3[3565258]: int(datas[2]) if datas[2]!="" else None, Jul 12 18:36:06 bots python3[3565258]: ^^^^^^^^^^^^^ Jul 12 18:36:06 bots python3[3565258]: ValueError: invalid literal for int() with base 10: 'None' Jul 12 18:36:06 bots systemd[1]: hebdobot-v3.service: Failed with result 'exit-code'. ```

La séquence suivante permet de reproduire le problème (ce qui explique #10):

  1. import des revues existantes:

    cp -ar /srv/hebdobot/reviews /srv/hebdobot-py/
    chown hebdobot\: /srv/hebdobot-py/reviews/*
    systemctl restart hebdobot-v3.service
    
  2. avec un client IRC, utiliser !stats avec succès

  3. avec un client IRC, démarrer revue suivie de la commande !stats

    !début
    #c'est le lundi
    blah
    blih
    % fini
    !fin
    !stats
    
  4. dans les logs (deux ligne ont été rajoutées pour dumper la variable datas ):

diff
 
git -C /srv/hebdobot-py/src/ diff 
diff --git a/review/stats.py b/review/stats.py
index 472a175..87a15cf 100644
--- a/review/stats.py
+++ b/review/stats.py
@@ -158,6 +158,8 @@ class ReviewStats:
                                 )
                             )
                         else:
+                            import logger
+                            logger.error(f"{datas=}")
                             self.datas.append(
                                 ReviewData(
                                     datetime.strptime(datas[0], "%Y%m%d-%Hh%M"),
    2024-07-15 00:13:56.080 - TO SERVER: PRIVMSG #april-test :% Fin de la revue hebdomadaire
    2024-07-15 00:13:56.080 - TO SERVER: PRIVMSG Pilou :Revue finie.
    2024-07-15 00:14:01.480 - FROM SERVER: :Pilou!~pilou@user/pilou PRIVMSG #april-test :!stats
    2024-07-15 00:14:01.480 - _dispatcher: all_raw_messages
    2024-07-15 00:14:01.480 - command: pubmsg, source: Pilou!~pilou@user/pilou, target: #april-test, arguments: ['!stats'], tags: None
    2024-07-15 00:14:01.480 - _dispatcher: pubmsg
    2024-07-15 00:14:01.480 - INFO - !stats caught.
    2024-07-15 00:14:01.480 - datas=['20100430-16h29', '10', '68']
    2024-07-15 00:14:01.480 - datas=['20100507-12h00', '5', 'None']
    
La séquence suivante permet de reproduire le problème (ce qui explique #10): 1. import des revues existantes: ``` cp -ar /srv/hebdobot/reviews /srv/hebdobot-py/ chown hebdobot\: /srv/hebdobot-py/reviews/* systemctl restart hebdobot-v3.service ``` 2. avec un client IRC, utiliser `!stats` avec succès 3. avec un client IRC, démarrer revue suivie de la commande `!stats` ``` !début #c'est le lundi blah blih % fini !fin !stats ``` 4. dans les logs (deux ligne ont été rajoutées pour dumper la variable `datas` ): <details><summary>diff</summary> <pre> git -C /srv/hebdobot-py/src/ diff diff --git a/review/stats.py b/review/stats.py index 472a175..87a15cf 100644 --- a/review/stats.py +++ b/review/stats.py @@ -158,6 +158,8 @@ class ReviewStats: ) ) else: + import logger + logger.error(f"{datas=}") self.datas.append( ReviewData( datetime.strptime(datas[0], "%Y%m%d-%Hh%M"), </pre> </details> <pre> 2024-07-15 00:13:56.080 - TO SERVER: PRIVMSG #april-test :% Fin de la revue hebdomadaire 2024-07-15 00:13:56.080 - TO SERVER: PRIVMSG Pilou :Revue finie. 2024-07-15 00:14:01.480 - FROM SERVER: :Pilou!~pilou@user/pilou PRIVMSG #april-test :!stats 2024-07-15 00:14:01.480 - _dispatcher: all_raw_messages 2024-07-15 00:14:01.480 - command: pubmsg, source: Pilou!~pilou@user/pilou, target: #april-test, arguments: ['!stats'], tags: None 2024-07-15 00:14:01.480 - _dispatcher: pubmsg 2024-07-15 00:14:01.480 - INFO - !stats caught. 2024-07-15 00:14:01.480 - datas=['20100430-16h29', '10', '68'] 2024-07-15 00:14:01.480 - datas=['20100507-12h00', '5', 'None'] </pre>

Ci dessous les différences entre le fichier reviewstats.csv "importé" et sa version réécrite après la fin de la 1ère review.

--- /srv/hebdobot-py/reviews/reviewstats.csv.ori        2024-07-16 20:45:31.120978260 +0200
+++ /srv/hebdobot-py/reviews/reviewstats.csv    2024-07-16 20:47:32.312910311 +0200
@@ -1,372 +1,372 @@
-20100430-16h29 10      68
-20100507-12h00 5
-20100515-12h00 5
-20100521-12h00 5
-20100528-12h00 5
-20100604-12h00 5
-20100611-12h00 5
+20100430-16h29 10      68
+20100507-12h00 5       None
+20100515-12h00 5       None
+20100521-12h00 5       None
+20100528-12h00 5       None
+20100604-12h00 5       None
+20100611-12h00 5       None
 20100618-12h00 10      24
-20100625-12h00 5
-20100702-12h00 5
+20100625-12h00 5       None
+20100702-12h00 5       None
 20100716-12h00 7       17
 20100723-12h00 6       18
 20100730-12h00 8       17
 20100806-12h00 7       15
 20100813-12h00 10      22
Ci dessous les différences entre le fichier reviewstats.csv "importé" et sa version réécrite après la fin de la 1ère review. ```diff --- /srv/hebdobot-py/reviews/reviewstats.csv.ori 2024-07-16 20:45:31.120978260 +0200 +++ /srv/hebdobot-py/reviews/reviewstats.csv 2024-07-16 20:47:32.312910311 +0200 @@ -1,372 +1,372 @@ -20100430-16h29 10 68 -20100507-12h00 5 -20100515-12h00 5 -20100521-12h00 5 -20100528-12h00 5 -20100604-12h00 5 -20100611-12h00 5 +20100430-16h29 10 68 +20100507-12h00 5 None +20100515-12h00 5 None +20100521-12h00 5 None +20100528-12h00 5 None +20100604-12h00 5 None +20100611-12h00 5 None 20100618-12h00 10 24 -20100625-12h00 5 -20100702-12h00 5 +20100625-12h00 5 None +20100702-12h00 5 None 20100716-12h00 7 17 20100723-12h00 6 18 20100730-12h00 8 17 20100806-12h00 7 15 20100813-12h00 10 22 ```
Owner

La sauvegarde des statistiques ajoute un "None" en texte. J'ai modifié ça après avoir ajouté un test supplémentaire qui reproduisait le souci.

La sauvegarde des statistiques ajoute un "None" en texte. J'ai modifié ça après avoir ajouté un test supplémentaire qui reproduisait le souci.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mindiell/hebdobot#9
No description provided.