diff --git a/jupyterlab_git/handlers.py b/jupyterlab_git/handlers.py index acc486b40..135913374 100644 --- a/jupyterlab_git/handlers.py +++ b/jupyterlab_git/handlers.py @@ -98,7 +98,11 @@ async def post(self, path: str = ""): ) if response["code"] != 0: - self.set_status(500) + if response["code"] == 128: + self.set_status(401) + else: + self.set_status(404) + self.finish(json.dumps(response)) @@ -198,7 +202,8 @@ async def post(self, path: str = ""): ) if result["code"] != 0: - self.set_status(500) + self.set_status(404) + self.finish(json.dumps(result)) @@ -601,7 +606,7 @@ async def post(self, path: str = ""): ) if response["code"] != 0: - self.set_status(500) + self.set_status(404) self.finish(json.dumps(response)) @@ -683,6 +688,8 @@ async def post(self, path: str = ""): set_upstream=True, force=force, ) + if response["code"] != 0: + self.set_status(401) else: response = { "code": 128, @@ -691,9 +698,8 @@ async def post(self, path: str = ""): ), "remotes": remotes, # Returns the list of known remotes } - - if response["code"] != 0: - self.set_status(500) + if response["code"] != 0: + self.set_status(404) self.finish(json.dumps(response)) diff --git a/jupyterlab_git/tests/test_handlers.py b/jupyterlab_git/tests/test_handlers.py index d9626795f..8820920a2 100644 --- a/jupyterlab_git/tests/test_handlers.py +++ b/jupyterlab_git/tests/test_handlers.py @@ -416,7 +416,7 @@ async def test_push_handler_noupstream(mock_git, jp_fetch, jp_root_dir): mock_git.remote_show.assert_called_with(str(local_path)) mock_git.push.assert_not_called() - assert response.code == 500 + assert response.code == 404 payload = json.loads(response.body) assert payload == { "code": 128, @@ -449,7 +449,7 @@ async def test_push_handler_multipleupstream(mock_git, jp_fetch, jp_root_dir): mock_git.remote_show.assert_called_with(str(local_path)) mock_git.push.assert_not_called() - assert response.code == 500 + assert response.code == 404 payload = json.loads(response.body) assert payload == { "code": 128,