From 8012a81ae7412f90158836142e47b138be507d3b Mon Sep 17 00:00:00 2001 From: Duc Trung Le Date: Wed, 18 Dec 2024 11:14:39 +0100 Subject: [PATCH] Handle RoomNotFound error on fork creation --- .../jupyter-server-ydoc/jupyter_server_ydoc/handlers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py b/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py index c3e768e5..e89ae266 100644 --- a/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py +++ b/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py @@ -642,7 +642,12 @@ async def put(self, root_roomid): Optionally keeps the fork in sync with the root. """ fork_roomid = uuid4().hex - root_room = await self._websocket_server.get_room(root_roomid) + try: + root_room = await self._websocket_server.get_room(root_roomid) + except RoomNotFound: + self.set_status(404) + self.finish({"code": 404, "error": "Room not found"}) + update = root_room.ydoc.get_update() fork_ydoc = Doc() fork_ydoc.apply_update(update)