element-hq / element-hq/synapse
Consider better error for username availability check invalid input
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#2397](https://github.com/matrix-org/synapse/issues/2397).
---
Currently querying an invalid input, such as `Wizard π3πππππ`, results in:
```
2017-07-23 20:24:09,231 - synapse.access.http.8008 - 59 - INFO - GET-3471131- 90.255.116.117 - 8008 - Received request: GET /_matrix/client/r0/register/available?username=Wizard%20%F0%9D%96%993%F0%9D%96%88%F0%9D%96%8D%F0%9D%96%8C%F0%9D%96%9A%F0%9D%96%9E
2017-07-23 20:24:09,232 - synapse.http.server - 139 - ERROR - GET-3471131- Failed handle request synapse.http.server._async_render on :
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/synapse/http/server.py", line 116, in wrapped_request_handler
yield request_handler(self, request, request_metrics)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/usr/lib/python2.7/dist-packages/synapse/http/server.py", line 255, in _async_render
callback_return = yield callback(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/usr/lib/python2.7/dist-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/usr/lib/python2.7/dist-packages/synapse/rest/client/v2_alpha/register.py", line 152, in on_GET
yield self.registration_handler.check_username(username)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1128, in _inlineCallbacks
result = g.send(result)
File "/usr/lib/python2.7/dist-packages/synapse/handlers/register.py", line 50, in check_username
if urllib.quote(localpart.encode('utf-8')) != localpart:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 7: ordinal not in range(128)
```
vector-im/riot-web/issues/4660 works around this, but for other clients could be handy to make the error more useful than a generic 500 ISE
Contributor guide
Assessment
This issue has not been assessed yet.