Agent FixboardAgentFixboard

web_fetch_tool ends the run on a URL with an invalid hostname

web_fetch_tool ends the run with httpx2.InvalidURL: Invalid IDNA hostname: 'example.com' when the model asks for https://example.com/.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
1
Fixed in
v2.46.0
Last checked

Verified fix: PR #8521 merged on . Fixed in v2.46.0 (first published release whose tag contains the merge commit). Last checked .

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, and httpx2.RequestError, then raises ModelRetry.
  • issubclass(httpx2.InvalidURL, ValueError) and issubclass(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 receives ModelRetry and the run continues.

If it still fails

  • The linked issue does not describe httpx2.InvalidURL ending the run on v2.46.0. Other fetch failures on this path were already ModelRetry.

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