Skip to content

fix: convert Pydantic HttpUrl to string for httpx proxy config#13

Merged
christopherjturner merged 2 commits into
DEFRA:mainfrom
ashimali:fix/pydantic-httpurl-fix
Oct 28, 2025
Merged

fix: convert Pydantic HttpUrl to string for httpx proxy config#13
christopherjturner merged 2 commits into
DEFRA:mainfrom
ashimali:fix/pydantic-httpurl-fix

Conversation

@ashimali

Copy link
Copy Markdown
Contributor

Pydantic v2's HttpUrl is not an httpx.URL and when passed directly to httpx.AsyncHTTPTransport(proxy=...), httpx tries to access .url attribute which doesn't exist in Pydantic v2. This causes runtime error if config.http_proxy is defined.

httpx.AsyncHTTPTransport accepts httpx.URL, str, or httpx.Proxy

Solution: wrap config.http_proxy with str() before passing to httpx

Pydantic v2's HttpUrl is not an httpx.URL and when passed directly
to httpx.AsyncHTTPTransport(proxy=...), httpx tries to access .url
attribute which doesn't exist in Pydantic v2. This causes runtime
error if config.http_proxy is defined.

httpx.AsyncHTTPTransport accepts httpx.URL, str, or httpx.Proxy

Solution: wrap config.http_proxy with str() before passing to httpx
@christopherjturner christopherjturner merged commit b62a6f5 into DEFRA:main Oct 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants