element-hq / element-hq/synapse

500 error when attempting to accept invite from unreachable server

Open
#4,665 0 comments 0 reactions 0 assignees View on GitHub
A-Federation A-Invite A-Validation O-Uncommon S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#4665](https://github.com/matrix-org/synapse/issues/4665).

---

My synapse just received an invite from a homeserver with a malformed .well-known entry:
```
{
"m.server": "https://datenverein.de"
}
```

This leads to pretty terrible user-facing failure mode: I received the invite, but joining yields "internal server error", while rejecting (in riot-web) does nothing until a cache reload. Although synapse decides not to retry the server fast enough, the log is still littered with errors for requests to it, e.g. from media or active requests to it like rejecting the invite (see below).

The obvious fix would be to not misconfigure servers :) but the failure mode could also need some improvements. I'm not sure what a good approach here is, but the ultimate goal would be to have a less frustrating user experience. Some of the puzzle pieces might be
* failing a little harder when bidirectional communication is broken with some federating server, e.g. rejecting invites from it
* more specific error messages?, right now there's no way to tell for users whether they did something wrong, their server did something wrong, some other server did something wrong, whether it's a temporary failure or a permanent one, or if it might be actionable.
* a standardized technical contact field in the .well-known file, perhaps even one that allows for automated "I failed to federate with you!" mails from synapse. As a server admin I currently have no good way to report to anyone at `datenverein.de` that there is a problem.

```
2019-02-18 09:43:40,019 - synapse.http.matrixfederationclient - 385 - WARNING - POST-693570- {GET-O-908408} [datenverein.de] Request failed: GET matrix://datenverein.de/_matrix/federation/v1/make_leave/%21lkCXzXfueTvyZLWWlP%3Adatenverein.de/%40Valodim%3Astratum0.org: InvalidCodepoint("Codepoint U+003A at position 6 of 'https://datenverein' not allowed",)
2019-02-18 09:43:40,020 - synapse.federation.federation_client - 540 - WARNING - POST-693570- Failed to make_leave via datenverein.de
Traceback (most recent call last):
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/http/federation/srv_resolver.py", line 127, in resolve_service
self._dns_client.lookupService(service_name),
twisted.names.error.DNSNameError: ]>
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/idna/core.py", line 270, in alabel
ulabel(label)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/idna/core.py", line 304, in ulabel
check_label(label)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/idna/core.py", line 261, in check_label
raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+003A at position 6 of 'https://datenverein' not allowed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/federation/federation_client.py", line 522, in _try_destination_list
res = yield callback(destination)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/federation/federation_client.py", line 589, in send_request
destination, room_id, user_id, membership, params,
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/federation/transport/client.py", line 253, in make_membership_event
ignore_backoff=ignore_backoff,
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/http/matrixfederationclient.py", line 638, in get_json
ignore_backoff=ignore_backoff,
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/opt/venvs/matrix-synapse/lib/python3.5/site-packages/synapse/http/matrixfederationclient.py", line 329, in _send_request
raise_from(RequestSendFailed(e, can_retry=True), e)
File "", line 3, in raise_from
synapse.api.errors.RequestSendFailed: Failed to send request: InvalidCodepoint: Codepoint U+003A at position 6 of 'https://datenverein' not allowed
2019-02-18 09:43:40,023 - synapse.handlers.room_member - 1022 - WARNING - POST-693570- Failed to reject invite: Failed to make_leave via any server
```

### Version information

synapse 0.99.1.1+stretch1, running on stratum0.org, malconfigured instance at datenverein.de

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.