Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 53284c4

Browse files
Fix a potential bug of UnboundLocalError (#8329)
Replaced with less buggier control flow
1 parent a3f124b commit 53284c4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

changelog.d/8329.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix UnboundLocalError from occuring when appservices send malformed register request.

synapse/rest/client/v2_alpha/register.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,14 @@ async def on_POST(self, request):
431431

432432
access_token = self.auth.get_access_token_from_request(request)
433433

434-
if isinstance(desired_username, str):
435-
result = await self._do_appservice_registration(
436-
desired_username, access_token, body
437-
)
438-
return 200, result # we throw for non 200 responses
434+
if not isinstance(desired_username, str):
435+
raise SynapseError(400, "Desired Username is missing or not a string")
436+
437+
result = await self._do_appservice_registration(
438+
desired_username, access_token, body
439+
)
440+
441+
return 200, result
439442

440443
# == Normal User Registration == (everyone else)
441444
if not self._registration_enabled:

0 commit comments

Comments
 (0)