element-hq / element-hq/synapse
3pid invite fails with a 500 if the IS returns a 500 (or is unreachable)
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#1549](https://github.com/matrix-org/synapse/issues/1549).
---
Trevor tried to do a 3pid invite by email in a small private room with me & Amandine and got a 500:
```
2016-05-18 11:23:47,000 - synapse.http.client - 92 - INFO - POST-674789 - Received response to POST https://matrix.org/_matrix/identity/api/v1/store-invite: 500
2016-05-18 11:23:47,000 - synapse.http.server - 135 - ERROR - POST-674789 - Failed handle request synapse.http.server._async_render on : clientproto=HTTP/1.1 site=8080>
Traceback (most recent call last):
File "synapse/http/server.py", line 114, in wrapped_request_handler
yield request_handler(self, request)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "synapse/http/server.py", line 260, in _async_render
callback_return = yield callback(request, **kwargs)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "synapse/rest/client/v1/room.py", line 481, in on_POST
txn_id
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "synapse/handlers/room_member.py", line 431, in do_3pid_invite
txn_id=txn_id
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "synapse/handlers/room_member.py", line 537, in _make_and_store_3pid_invite
inviter_avatar_url=inviter_avatar_url
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "synapse/handlers/room_member.py", line 640, in _ask_id_server_for_third_party_invite
invite_config
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1128, in _inlineCallbacks
result = g.send(result)
File "synapse/http/client.py", line 127, in post_urlencoded_get_json
defer.returnValue(json.loads(body))
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/simplejson/__init__.py", line 516, in loads
return _default_decoder.decode(s)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/mnt/disk/home/matrix/venv-synapse/local/lib/python2.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2016-05-18 11:23:47,001 - synapse.access.http.8080 - 91 - INFO - POST-674789 - 46.247.9.153 - 8080 - {@trevorm:matrix.org} Processed request: 255ms (0ms, 0ms) (0ms/0) 55B 500 "POST /_matrix/client/r0/rooms/!UFXRtuwBNRjrwPSNKd
:matrix.org/invite?access_token= HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
```
(Imported from https://matrix.org/jira/browse/SYN-698)
(Reported by @ara4n)
Contributor guide
Research direction
Start in synapse/handlers/room_member.py at _ask_id_server_for_third_party_invite and follow its call to synapse/http/client.py, post_urlencoded_get_json. Reproduce the request with the identity server returning HTTP 500 or being unreachable, then verify the resulting client response no longer exposes the unhandled JSONDecodeError and matches the intended failure behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100