poljar / weechat-matrix

Weechat Matrix protocol script written in python
Other
957 stars 119 forks source link

Ignore own messages without room_id #282

Open jspricke opened 3 years ago

jspricke commented 3 years ago

I got this backtrace:

Traceback (most recent call last): File ".weechat/python/matrix/utf.py", line 89, in wrapper return function(*args, **kwargs) File ".weechat/python/autoload/matrix.py", line 343, in receive_cb server.handle_response(response) File ".weechat/python/matrix/server.py", line 1621, in handle_response self.handle_error_response(response) File ".weechat/python/matrix/server.py", line 1591, in handle_error_response self.handle_own_messages_error(response) File ".weechat/python/matrix/server.py", line 1234, in handle_own_messages_error room_buffer = self.room_buffers[response.room_id] KeyError: ''

Not sure if ignoring is the best solution but probably better then throwing an exception.

poljar commented 3 years ago

Any more info about that error, did another traceback happen before whas there some user interaction before that happened?

That method is used to print out messages that you sent out, so it's strange that you sent a message in a buffer that doesn't exist.

jspricke commented 3 years ago

I've found the error four times in my logs, every time I've send a message to someone at the same time. Nothing else in the logs around that time. Anything else I should check?

poljar commented 3 years ago

Actually looking at this, the key that it's using is an empty string, e.g. Python prints out the key in the traceback:

>>> x["a"]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'a'

The room id is passed into the method that is sending out the request and added to the response, it's not part of the server response. Something strange is going on, could you expand on what "at the same time" means?

jspricke commented 3 years ago
Message by me Traceback
2021-04-23 23:23:15 2021-04-23 23:23:21
no new message 2021-04-23 23:23:35
2021-06-22 10:03:20 2021-06-22 10:03:23
2021-06-22 10:04:06 2021-06-22 10:04:09

Also logs from python.server.matrix_org.weechatlog:

2021-04-23 03:06:16     --      matrix: Already logged in, syncing...
2021-04-23 23:23:21     =!=     matrix: Error: RoomSendError: 520 unknown error
2021-04-23 23:23:35     =!=     matrix: Error: RoomSendError: 520 unknown error
2021-04-23 23:24:49     --      matrix: disconnected from server
2021-06-22 03:56:13     --      matrix: Already logged in, syncing...
2021-06-22 10:03:23     =!=     matrix: Error: RoomSendError: 429 unknown error
2021-06-22 10:04:09     =!=     matrix: Error: RoomSendError: 429 unknown error
2021-06-22 10:10:12     =!=     matrix: Error: SyncError: 520 unknown error
2021-06-22 10:10:12     --      matrix: disconnected from server
poljar commented 3 years ago

Message by me Traceback 2021-04-23 23:23:15 2021-04-23 23:23:21 no new message 2021-04-23 23:23:35 2021-06-22 10:03:20 2021-06-22 10:03:23 2021-06-22 10:04:06 2021-06-22 10:04:09

Also logs from python.server.matrix_org.weechatlog:

2021-04-23 03:06:16     --      matrix: Already logged in, syncing...
2021-04-23 23:23:21     =!=     matrix: Error: RoomSendError: 520 unknown error
2021-04-23 23:23:35     =!=     matrix: Error: RoomSendError: 520 unknown error
2021-04-23 23:24:49     --      matrix: disconnected from server
2021-06-22 03:56:13     --      matrix: Already logged in, syncing...
2021-06-22 10:03:23     =!=     matrix: Error: RoomSendError: 429 unknown error
2021-06-22 10:04:09     =!=     matrix: Error: RoomSendError: 429 unknown error
2021-06-22 10:10:12     =!=     matrix: Error: SyncError: 520 unknown error
2021-06-22 10:10:12     --      matrix: disconnected from server

That almost explains it, but we make sure that the error type takes another path, only a valid RoomSendMessage response gets passed to that method: https://github.com/poljar/weechat-matrix/blob/master/matrix/server.py#L1641