Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluggable Modules - Account validity callbacks - on_user_registration #17015

Closed
YinshenTaoX opened this issue Mar 21, 2024 · 0 comments
Closed

Comments

@YinshenTaoX
Copy link

Description

My code:
class ZebraModule: def __init__(self, config: ZebraModuleConfig, api: ModuleApi): # Keep a reference to the config and Module API self._api = api self._config = config self._api.register_account_validity_callbacks(on_user_registration=self.on_user_registration) async def on_user_registration(user: str) -> None: try: logger.log(logging.INFO,f"user_id: {user}") except Exception as e: logger.error(e)

The register process will be looped infinity

Docker log:
2024-03-21 06:53:44,271 - synapse.http.server - 130 - INFO - POST-6650 - <XForwardedForRequest at 0xffff88d2e890 method='POST' uri='/_matrix/client/v3/register' clientproto='HTTP/1.1' site='synapse-homeserver'> SynapseError: 400 - User ID already taken.
2024-03-21 06:53:44,272 - synapse.access.http.synapse-homeserver - 472 - INFO - POST-6650 - ::ffff:172.27.0.1 - synapse-homeserver - {None} Processed request: 0.001sec/0.000sec (0.001sec, 0.000sec) (0.000sec/0.001sec/3) 60B 400 "POST /_matrix/client/v3/register HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" [0 dbevts]

And infinite loop...

Steps to reproduce

add the module on_user_registration
register a new user

Homeserver

matrix.org

Synapse Version

localhost:8008

Installation Method

Docker (matrixdotorg/synapse)

Database

single PostgreSQL server

Workers

Single process

Platform

mac M2

Configuration

No response

Relevant log output

2024-03-21 06:53:27,167 - synapse.http.server - 146 - ERROR - POST-19 - Failed handle request via 'RegisterRestServlet': <XForwardedForRequest at 0xffff8b6d2b50 method='POST' uri='/_matrix/client/v3/register' clientproto='HTTP/1.1' site='synapse-homeserver'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/synapse/http/server.py", line 332, in _async_render_wrapper
    callback_return = await self._async_render(request)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synapse/http/server.py", line 544, in _async_render
    callback_return = await raw_callback_return
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synapse/rest/client/_base.py", line 109, in wrapped
    return await orig(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synapse/rest/client/register.py", line 699, in on_POST
    registered_user_id = await self.registration_handler.register_user(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/synapse/handlers/register.py", line 307, in register_user
    await self.register_with_store(
  File "/usr/local/lib/python3.11/site-packages/synapse/handlers/register.py", line 763, in register_with_store
    await self._account_validity_handler.on_user_registration(user_id)
  File "/usr/local/lib/python3.11/site-packages/synapse/handlers/account_validity.py", line 105, in on_user_registration
    await callback(user_id)
          ^^^^^^^^^^^^^^^^^
TypeError: ZebraModule.on_user_registration() takes 1 positional argument but 2 were given
2024-03-21 06:53:27,170 - synapse.access.http.synapse-homeserver - 472 - INFO - POST-19 - ::ffff:172.27.0.1 - synapse-homeserver - {None} Processed request: 0.286sec/0.000sec (0.247sec, 0.004sec) (0.001sec/0.036sec/11) 55B 500 "POST /_matrix/client/v3/register HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" [0 dbevts]
2024-03-21 06:53:27,180 - synapse.http.server - 130 - INFO - POST-21 - <XForwardedForRequest at 0xffff8a9a8250 method='POST' uri='/_matrix/client/v3/register' clientproto='HTTP/1.1' site='synapse-homeserver'> SynapseError: 400 - User ID already taken.
2024-03-21 06:53:27,180 - synapse.access.http.synapse-homeserver - 472 - INFO - POST-21 - ::ffff:172.27.0.1 - synapse-homeserver - {None} Processed request: 0.005sec/0.000sec (0.001sec, 0.000sec) (0.000sec/0.003sec/3) 60B 400 "POST /_matrix/client/v3/register HTTP

Anything else that would be useful to know?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant