From 265a94cd602f9cdadb58edd6eac34325b5ccaef4 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 30 Apr 2026 17:42:17 -0700 Subject: [PATCH] tests(vcr): force pure-httpx transport when VCR is active litellm's default LiteLLMAiohttpTransport routes requests through aiohttp, which sits below httpx and is invisible to vcrpy's httpx-stub interception. Under vcrpy + aiohttp, requests reach the real network but responses come back through the stubbed httpx transport as empty 200s, surfacing as 'Unable to get json response - Expecting value: line 1 column 1 (char 0)' in providers like Anthropic, Gemini, and any other path that exercises the aiohttp transport. Disabling the aiohttp transport when the VCR persister is registered forces all calls through pure httpx, which vcrpy can record and replay correctly. --- tests/llm_responses_api_testing/conftest.py | 5 +++++ tests/llm_translation/conftest.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tests/llm_responses_api_testing/conftest.py b/tests/llm_responses_api_testing/conftest.py index 01257cd26be..948debbf95c 100644 --- a/tests/llm_responses_api_testing/conftest.py +++ b/tests/llm_responses_api_testing/conftest.py @@ -97,6 +97,11 @@ def pytest_recording_configure(config, vcr): if _vcr_disabled(): return vcr.register_persister(make_redis_persister()) + # vcrpy patches httpx's transport; litellm's default AiohttpTransport + # routes around httpx and produces empty responses under the patched + # transport. Force pure-httpx transport so vcrpy can record/replay. + litellm.disable_aiohttp_transport = True + os.environ["DISABLE_AIOHTTP_TRANSPORT"] = "True" @pytest.fixture(scope="session") diff --git a/tests/llm_translation/conftest.py b/tests/llm_translation/conftest.py index 132ebd57ad8..2215b1c24b4 100644 --- a/tests/llm_translation/conftest.py +++ b/tests/llm_translation/conftest.py @@ -121,6 +121,11 @@ def pytest_recording_configure(config, vcr): if _vcr_disabled(): return vcr.register_persister(make_redis_persister()) + # vcrpy patches httpx's transport; litellm's default AiohttpTransport + # routes around httpx and produces empty responses under the patched + # transport. Force pure-httpx transport so vcrpy can record/replay. + litellm.disable_aiohttp_transport = True + os.environ["DISABLE_AIOHTTP_TRANSPORT"] = "True" # ---------------------------------------------------------------------------