The Fix
Fixes the handling of redirects with authentication, ensuring that users will no longer receive a ValueError when encountering multiple authenticated URLs in a redirect chain.
Based on closed aio-libs/aiohttp issue #9436 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Authentication provided by a redirect now takes precedence over provided ``auth`` when making requests with the client -- by :user:`PLPeeters`.
diff --git a/aiohttp/client.py b/aiohttp/client.py
index 343d20436e7..15c89018ffb 100644
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
await session.get('http://itheka.gr', allow_redirects=True)
if __name__ == "__main__":
asyncio.run(main())
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nFixes the handling of redirects with authentication, ensuring that users will no longer receive a ValueError when encountering multiple authenticated URLs in a redirect chain.\nWhen NOT to use: This fix is not applicable if the redirect behavior is intentionally designed to raise ValueError.\n\n
Why This Fix Works in Production
- Trigger: >> import aiohttp
- Mechanism: The client incorrectly raises a ValueError instead of TooManyRedirects for authenticated redirects
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The client incorrectly raises a ValueError instead of TooManyRedirects for authenticated redirects
- Surfaces as: >> import aiohttp
Proof / Evidence
- GitHub issue: #9436
- Fix PR: https://github.com/aio-libs/aiohttp/pull/9443
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.44
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I don't think that check should be happening on redirects, only on the original url parameter. So, option 2. I'm also wondering if we should…”
“It probably makes sense to just move that check to somewhere before the loop.”
Failure Signature (Search String)
- >> import aiohttp
Error Message
Stack trace
Error Message
-------------
>> import aiohttp
>> import asyncio
>>
>>
>> async def main():
... async with aiohttp.ClientSession() as session:
... await session.get('http://itheka.gr', allow_redirects=True)
...
>>
>> if __name__ == "__main__":
... asyncio.run(main())
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "<stdin>", line 3, in main
File "/Users/peetersp/Documents/Swan/website-processors/venv/lib/python3.12/site-packages/aiohttp/client.py", line 591, in _request
raise ValueError(
ValueError: Cannot combine AUTH argument with credentials encoded in URL
Minimal Reproduction
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
await session.get('http://itheka.gr', allow_redirects=True)
if __name__ == "__main__":
asyncio.run(main())
Environment
- Python: 3.12
What Broke
Users experience unexpected ValueError when following authenticated redirects.
Why It Broke
The client incorrectly raises a ValueError instead of TooManyRedirects for authenticated redirects
Fix Options (Details)
Option A — Apply the official fix
Fixes the handling of redirects with authentication, ensuring that users will no longer receive a ValueError when encountering multiple authenticated URLs in a redirect chain.
Fix reference: https://github.com/aio-libs/aiohttp/pull/9443
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the redirect behavior is intentionally designed to raise ValueError.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
- Add a long-running test that repeats the failing call path and asserts stable memory.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.