diff --git a/deepset_cloud_sdk/_s3/upload.py b/deepset_cloud_sdk/_s3/upload.py index e97aa0ed..c82ba94f 100644 --- a/deepset_cloud_sdk/_s3/upload.py +++ b/deepset_cloud_sdk/_s3/upload.py @@ -146,7 +146,7 @@ async def _upload_file_with_retries( raise RetryableHttpError(cre) from cre try: - error_message = await response.json() + error_message = await response.text() cre.message = cre.message + f" - {error_message}" except Exception: # pylint: disable=broad-except pass diff --git a/tests/unit/s3/test_upload.py b/tests/unit/s3/test_upload.py index 0307deea..b6eb0721 100644 --- a/tests/unit/s3/test_upload.py +++ b/tests/unit/s3/test_upload.py @@ -227,10 +227,10 @@ async def test_upload_file_does_not_retry_for_exception( ) with patch.object(aiohttp.ClientSession, "post") as post_mock: post_mock.return_value.__aenter__.return_value.raise_for_status = MagicMock(side_effect=exception) - post_mock.return_value.__aenter__.return_value.json.return_value = {"error": "error"} + post_mock.return_value.__aenter__.return_value.text.return_value = "error" s3 = S3() - with pytest.raises(aiohttp.ClientResponseError, match="reason - {'error': 'error'}"): + with pytest.raises(aiohttp.ClientResponseError, match="reason - error"): await s3._upload_file_with_retries("one.txt", upload_session_response, "123", mock_session) @pytest.mark.parametrize("status", [400, 422, 501]) @@ -243,7 +243,7 @@ async def test_upload_file_does_not_retry_for_exception_failing_json( ) with patch.object(aiohttp.ClientSession, "post") as post_mock: post_mock.return_value.__aenter__.return_value.raise_for_status = MagicMock(side_effect=exception) - post_mock.return_value.__aenter__.return_value.json.side_effect = Exception("error") + post_mock.return_value.__aenter__.return_value.text.side_effect = Exception("error") s3 = S3() with pytest.raises(aiohttp.ClientResponseError, match="reason"):