matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.79k stars 2.13k forks source link

`TypeError` on room creation due to invalid ratelimit config #14495

Closed zfnmxt closed 1 year ago

zfnmxt commented 1 year ago

Description

Getting this type error when attempting to create a room:

 synapse.http.server: [POST-61] Failed handle request via 'RoomCreateRestServlet': <XForwardedForRequest at 0x7f7468745600 method='POST' uri='/_matrix/client/r0/createRoom' clientproto='HTTP/1.1' site='8008'>
                                       Traceback (most recent call last):
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/http/server.py", line 307, in _async_render_wrapper
                                           callback_return = await self._async_render(request)
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/http/server.py", line 513, in _async_render
                                           callback_return = await raw_callback_return
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/rest/client/room.py", line 161, in on_POST
                                           info, _ = await self._room_creation_handler.create_room(
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/handlers/room.py", line 757, in create_room
                                           await self.request_ratelimiter.ratelimit(requester)
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/api/ratelimiting.py", line 394, in ratelimit
                                           await self.request_ratelimiter.ratelimit(
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/api/ratelimiting.py", line 296, in ratelimit
                                           allowed, time_allowed = await self.can_do_action(
                                         File "/nix/store/5hs8i5pz0na7qpg15rhg9i45z5bby13p-matrix-synapse-1.71.0/lib/python3.10/site-packages/synapse/api/ratelimiting.py", line 167, in can_do_action
                                           performed_count = action_count - time_delta * rate_hz
                                       TypeError: can't multiply sequence by non-int of type 'float'

Steps to reproduce

  1. Try to create a room.
  2. Get error!

Homeserver

zfnmxt.com

Synapse Version

1.71.0

Installation Method

Other (please mention below)

Platform

NixOS unstable channel; synapse installed via Nix.

Relevant log output

First 1000 lines of my log since start-up, including multiple instances of the aforementioned error: https://gist.github.com/zfnmxt/2905a21b37b2d43540833e51cef18888

Anything else that would be useful to know?

No response

DMRobertson commented 1 year ago

Does your homeserver's configuration file contain any settings related to ratelimiting?

zfnmxt commented 1 year ago

@DMRobertson Yes, and this was indeed the issue. Looks like an older version of the option in NixOS expected a string, hence the type error. Thanks! :)

DMRobertson commented 1 year ago

No worries, glad you could figure it out.

Note that #12651 would help a lot here!