From cbe69723b19f755e610494e8fd4ac3bdc963cbf4 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2026 14:30:27 -0700 Subject: [PATCH] test(s3_v2): pin async 5xx retry through the production AsyncHTTPHandler (#43080) * test(s3_v2): pin async 5xx retry through the production AsyncHTTPHandler Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * Update tests/unit/integrations/test_s3_v2.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: shivam Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Mrinal Chanshetty Co-authored-by: yucheng-berri Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- tests/unit/integrations/test_s3_v2.py | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/integrations/test_s3_v2.py b/tests/unit/integrations/test_s3_v2.py index caab4ff561d..e9f5e667421 100644 --- a/tests/unit/integrations/test_s3_v2.py +++ b/tests/unit/integrations/test_s3_v2.py @@ -672,6 +672,36 @@ async def test_async_upload_exhausts_403_retries_through_production_http_handler assert "Error uploading to s3" in caplog.text +@pytest.mark.asyncio +@pytest.mark.parametrize("transient_status", [500, 503]) +async def test_async_upload_recovers_from_transient_5xx_through_production_http_handler( + transient_status: int, rotating_profile: str, caplog: pytest.LogCaptureFixture +): + """ + AsyncHTTPHandler.put raises MaskedHTTPStatusError on 5xx instead of returning the response, so a retry + loop that only inspects returned status codes never runs (#42868). + """ + test_element = s3BatchLoggingElement( + s3_object_key=f"2025-09-14/test-{transient_status}.json", + payload={"test": str(transient_status)}, + s3_object_download_filename=f"test-{transient_status}.json", + ) + async with _s3_logger_on_production_handler(rotating_profile, [transient_status, 200]) as ( + logger, + requests, + mock_sleep, + ): + uploaded = await logger.async_upload_data_to_s3(test_element) + + assert uploaded is True + assert len(requests) == 2 + assert all(request.method == "PUT" for request in requests) + assert requests[0].url == requests[1].url + assert requests[0].content == requests[1].content + mock_sleep.assert_awaited_once_with(1) + assert "Error uploading to s3" not in caplog.text + + @pytest.mark.asyncio async def test_async_upload_is_single_attempted_on_404_through_production_http_handler(rotating_profile: str, caplog): test_element = s3BatchLoggingElement(