Symptom
web_fetch_tool ends the run with httpx2.InvalidURL: Invalid IDNA hostname: 'example.com' when the model asks for https://example.com/.
Evidence what you'll see
- The handler catches
ValueError,httpx2.HTTPStatusError, andhttpx2.RequestError, then raisesModelRetry. issubclass(httpx2.InvalidURL, ValueError)andissubclass(httpx2.InvalidURL, httpx2.RequestError)are both false.
Why it happens
httpx2.InvalidURL is not one of the exceptions the tool catches, so it escapes the tool. The URL never reaches the network.
Affected versions
The linked issue does not name a Pydantic AI version, a Python version, or an operating system. The trigger is a hostname that fails IDNA parsing.
Fix steps
0 of 1 done
Your check marks stay in this browser only.
How to check it worked
- Have the agent fetch
https://example.com/and confirm the model receivesModelRetryand the run continues.
If it still fails
- The linked issue does not describe
httpx2.InvalidURLending the run onv2.46.0. Other fetch failures on this path were alreadyModelRetry.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it