Ensure failed oauth registration response is read before accessing response.text (#1118)

Co-authored-by: ihrpr <inna@anthropic.com>
This commit is contained in:
Jeremiah Lowin 2025-07-10 17:01:17 -04:00 • committed by GitHub
commit 81fe63a81d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -308,6 +308,7 @@ class OAuthClientProvider(httpx.Auth):
async def _handle_registration_response(self, response: httpx.Response) -> None:
"""Handle registration response."""
if response.status_code not in (200, 201):
await response.aread()
raise OAuthRegistrationError(f"Registration failed: {response.status_code} {response.text}")
try: