Open DMRobertson opened 3 years ago
We have code which catches DomainError and reraises.
While looking into this I observed that this code is duplicated in Synapse, see https://github.com/matrix-org/matrix-python-common/issues/2 . So it seems reasonable treat this as a library function whose behaviour is not to be altered.
So let's look at the call stack instead to find a suitable place to catch the error.
DNSServerError: <Message id=51167 rCode=2 maxSize=0 flags=answer,recDes,recAv queries=[Query(b'_matrix._tcp.matrix.dagonismyfear.duckdns.org', 33, 1)]>
File "sydent/http/servlets/__init__.py", line 184, in render
result = await f(self, request)
File "sydent/http/servlets/registerservlet.py", line 78, in render_POST
1024 * 5,
File "sydent/http/httpclient.py", line 60, in get_json
uri.encode("utf8"),
File "twisted/internet/defer.py", line 1658, in _inlineCallbacks
cast(Failure, result).throwExceptionIntoGenerator, gen
File "twisted/python/failure.py", line 500, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "sydent/http/matrixfederationagent.py", line 153, in request
routing = yield defer.ensureDeferred(self._route_matrix_uri(parsed_uri))
File "twisted/internet/defer.py", line 1658, in _inlineCallbacks
cast(Failure, result).throwExceptionIntoGenerator, gen
File "twisted/python/failure.py", line 500, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "sydent/http/matrixfederationagent.py", line 278, in _route_matrix_uri
server_list = await self._srv_resolver.resolve_service(service_name)
File "sydent/http/srvresolver.py", line 157, in resolve_service
raise e
File "sydent/http/srvresolver.py", line 142, in resolve_service
answers, _, _ = await self._lookup_service(service_name.decode())
matrixfederationagent also appears to be library ish (shared with Synapse); see matrix-org/matrix-python-common#3
https://sentry.matrix.org/sentry/sydent/issues/235982/?query=is%3Aunresolved
We got
Twisted docs say that anything in https://twistedmatrix.com/documents/current/api/twisted.names.error.html may be raised. In particular, the parent class
DomainError
. We could account for this case by catching DomainError too and returning an appropriate status code + response.