This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Using Synapse Admin API to add a user fails when request contains "msisdn" third-party ID #13225
Labels
A-Admin-API
good first issue
Good for newcomers
S-Minor
Blocks non-critical functionality, workarounds exist.
T-Defect
Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Description
According to the documentation here you should be able to set a list of third-party IDs in the request body when adding a User. These can have a "medium" field of either "email" for an email address, or "msisdn" for a phone number.
When attempting to add a new user with a third-party ID of type "msisdn", the request fails, returning a 500 Internal Server Error, and an error code of "M_UNKNOWN".
Checking the logs, it appears that Synapse is treating the address field of the "msisdn" third-party ID as an email address. This can be seen from a log statement saying "Couldn't parse email address [redacted-phone-number]".
I've had a brief look at the code, and it seems that the issue may caused by the for loop in synapse/rest/admin/users.py when adding a new user (line 367 of users.py).
Synapse appears to iterate across all of the third party IDs from the request body, and calls "self.auth_handler.add_threepid()" on them. After adding a threepid, there is an if statement checking if email notifications are enabled, and enabled for new users. If this resolves to true, "self.pusher_pool.add_pusher()" is called.
The arguments passed to the add_pusher() method are hard-coded to email, even when the threepid is of type "msisdn". This seems to cause the add_pusher() method to attempt to parse a phone number as an email address and fail, leading to a 500 internal server error.
Steps to reproduce
Expected Functionality
Actual Functionality
Note: Matrix user ID, password, msisdn phone number changed for privacy
Homeserver
Self-hosted homeserver, on my local network, non-public
Synapse Version
1.50.1
Installation Method
Other (please mention below)
Platform
deployed in docker container on CentOS 7, using matrix-docker-ansible-deploy project.
Relevant log output
Anything else that would be useful to know?
I can use the same endpoint to "modify" an existing User, and add a "msisdn" third-party ID to them. This works successfully. The issue only seems to occur when using the endpoint to "add" a new User.
The text was updated successfully, but these errors were encountered: