summary refs log tree commit diff
diff options
context:
space:
mode:
authorqashlan <ahmedelqashlan@gmail.com>2025-02-12 16:06:21 +0200
committerGitHub <noreply@github.com>2025-02-12 14:06:21 +0000
commit816054b0122fa88cde71ca03aee7f97f382af89b (patch)
treefac9fb40a1a4bedc788a03f72a9d1c068edd5283
parentBump ulid from 1.1.4 to 1.2.0 (#18148) (diff)
downloadsynapse-816054b0122fa88cde71ca03aee7f97f382af89b.tar.xz
Fix internal server error when updating 3pid address with invalid email (#18125)
When updating 3pid for a user email from admin api and sending invalid
email the server throws 500 internal server error.
changed to 400 Bad request and returned the error message

Signed-off-by: qashlan <ahmedelqashlan@gmail.com>
Signed-off-by: Ahmed Qashlan <ahmedelqashlan@gmail.com>
-rw-r--r--changelog.d/18125.bugfix1
-rw-r--r--synapse/handlers/auth.py10
2 files changed, 9 insertions, 2 deletions
diff --git a/changelog.d/18125.bugfix b/changelog.d/18125.bugfix
new file mode 100644

index 0000000000..0e6aa704ff --- /dev/null +++ b/changelog.d/18125.bugfix
@@ -0,0 +1 @@ +Fix a bug when updating a user 3pid with invalid returns 500 server error change to 400 with a message. \ No newline at end of file diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 1f4264ad7e..e96922c08d 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py
@@ -1579,7 +1579,10 @@ class AuthHandler: # for the presence of an email address during password reset was # case sensitive). if medium == "email": - address = canonicalise_email(address) + try: + address = canonicalise_email(address) + except ValueError as e: + raise SynapseError(400, str(e)) await self.store.user_add_threepid( user_id, medium, address, validated_at, self.hs.get_clock().time_msec() @@ -1610,7 +1613,10 @@ class AuthHandler: """ # 'Canonicalise' email addresses as per above if medium == "email": - address = canonicalise_email(address) + try: + address = canonicalise_email(address) + except ValueError as e: + raise SynapseError(400, str(e)) await self.store.user_delete_threepid(user_id, medium, address)