Skip to content
Snippets Groups Projects
Unverified Commit 70af98e3 authored by Serban Constantin's avatar Serban Constantin Committed by Serban Constantin
Browse files

return NotFoundError if room not found

Per the Client-Server API[0] we should return
`M_NOT_FOUND` if the room isn't found instead
of generic SynapseError.

This ensures that /directory/list API returns
404 for room not found instead of 400.

[0]: https://matrix.org/docs/spec/client_server/unstable.html#get-matrix-client-r0-directory-list-room-roomid



Signed-off-by: default avatarSerban Constantin <serban.constantin@gmail.com>
parent 5e2ee646
No related branches found
No related tags found
No related merge requests found
...@@ -62,4 +62,7 @@ Christoph Witzany <christoph at web.crofting.com> ...@@ -62,4 +62,7 @@ Christoph Witzany <christoph at web.crofting.com>
* Add LDAP support for authentication * Add LDAP support for authentication
Pierre Jaury <pierre at jaury.eu> Pierre Jaury <pierre at jaury.eu>
* Docker packaging * Docker packaging
\ No newline at end of file
Serban Constantin <serban.constantin at gmail dot com>
* Small bug fix
\ No newline at end of file
/directory/list API returns 404 for room not found instead of 400
\ No newline at end of file
...@@ -18,7 +18,7 @@ import logging ...@@ -18,7 +18,7 @@ import logging
from twisted.internet import defer from twisted.internet import defer
from synapse.api.errors import AuthError, Codes, SynapseError from synapse.api.errors import AuthError, Codes, NotFoundError, SynapseError
from synapse.http.servlet import parse_json_object_from_request from synapse.http.servlet import parse_json_object_from_request
from synapse.types import RoomAlias from synapse.types import RoomAlias
...@@ -159,7 +159,7 @@ class ClientDirectoryListServer(ClientV1RestServlet): ...@@ -159,7 +159,7 @@ class ClientDirectoryListServer(ClientV1RestServlet):
def on_GET(self, request, room_id): def on_GET(self, request, room_id):
room = yield self.store.get_room(room_id) room = yield self.store.get_room(room_id)
if room is None: if room is None:
raise SynapseError(400, "Unknown room") raise NotFoundError("Unknown room")
defer.returnValue((200, { defer.returnValue((200, {
"visibility": "public" if room["is_public"] else "private" "visibility": "public" if room["is_public"] else "private"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment