diff --git a/src/zulip_write_only_proxy/models.py b/src/zulip_write_only_proxy/models.py index bb76fa59..b8fb2799 100644 --- a/src/zulip_write_only_proxy/models.py +++ b/src/zulip_write_only_proxy/models.py @@ -48,7 +48,10 @@ def upload_file(self, file: IO[Any]): def get_stream_topics(self): stream = self._client.get_stream_id(self.stream) if stream["result"] != "success": - log.error(f"failed to get stream id for {self.stream}", extra=stream) + log.error( + f"failed to get stream id for {self.stream}, " + f"zulip api response: {stream}" + ) return stream stream_id = stream["stream_id"] return self._client.get_stream_topics(stream_id) diff --git a/tests/test_models.py b/tests/test_models.py index 780fa281..3185aa98 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -36,12 +36,21 @@ def test_get_stream_topics(scoped_client): def test_get_stream_topics_log(scoped_client, caplog: pytest.LogCaptureFixture): - scoped_client._client.get_stream_id = MagicMock(return_value={"result": "failure"}) + scoped_client._client.get_stream_id = MagicMock( + return_value={ + "code": "BAD_REQUEST", + "msg": "Invalid stream name 'nonexistent'", + "result": "error", + } + ) scoped_client.get_stream_topics() assert len(caplog.records) == 1 - assert caplog.records[0].message == "failed to get stream id for Test Stream" + assert caplog.records[0].message == ( + "failed to get stream id for Test Stream, zulip api response: " + f"{scoped_client._client.get_stream_id.return_value}" + ) def test_send_message(scoped_client):