Skip to content

[Docs] Fix HTTP migration and async session references - #5079

Merged
hanouticelina merged 2 commits into
huggingface:mainfrom
Yuilona:docs/fix-http-migration-guidance
Oct 5, 2026
Merged

hanouticelina merged 2 commits into
huggingface:mainfrom
Yuilona:docs/fix-http-migration-guidance

Conversation

@Yuilona

@Yuilona Yuilona commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The v1 migration guide recommends huggingface_hub.HfHubHttpError, which does not exist. Point to HfHubHTTPError and show the huggingface_hub.utils import that works on both v0.36.0 and v1.0.0.
  • Point the AsyncInferenceClient / trust_env migration advice to set_async_client_factory. The synchronous factory does not configure async sessions.
  • Fix the async factory's API documentation link from the nonexistent get_async_client to get_async_session.

These are documentation-only corrections; the historical v1 guide keeps its httpx references. No runtime behavior changes.

Verified the imports and factory behavior offline against v0.36.0, v1.0.0, and current main. For example, on v1.0.0:

import asyncio
import httpx
import huggingface_hub
from huggingface_hub import set_async_client_factory
from huggingface_hub.utils import HfHubHTTPError, get_async_session

print(hasattr(huggingface_hub, "HfHubHttpError"))
print(HfHubHTTPError.__name__)
print(issubclass(HfHubHTTPError, httpx.HTTPError))

calls = []

def factory():
    calls.append("async")
    return httpx.AsyncClient(trust_env=False)

async def main():
    set_async_client_factory(factory)
    async with get_async_session():
        print(calls)

asyncio.run(main())
False
HfHubHTTPError
True
['async']

make style and make quality both passed (using mingw32-make with PYTHONUTF8=1 on Windows). Existing HTTP compatibility/session tests also passed:

python -m pytest tests/test_utils_http.py::test_httpx_compatibility_export tests/test_utils_http.py::TestConfigureSession -q
7 passed in 0.67s

AI-assisted: prepared and validated with Codex.


Note

Low Risk
Documentation-only edits to the migration guide and a docstring; no library behavior changes.

Overview
Corrects v1 HTTP migration documentation and one async HTTP factory docstring so they match the real public API—no runtime behavior changes.

The migration guide now points error handling at HfHubHTTPError (not the nonexistent HfHubHttpError) with from huggingface_hub.utils import HfHubHTTPError, and tells users disabling trust_env for AsyncInferenceClient to use set_async_client_factory instead of the sync set_client_factory. In _http.py, set_async_client_factory’s docs now reference get_async_session instead of the missing get_async_client.

Reviewed by Cursor Bugbot for commit 0648b28. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

bot-ci-comment Bot commented Oct 5, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@hanouticelina
hanouticelina merged commit d699913 into huggingface:main Oct 5, 2026
26 of 27 checks passed
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v2.2.0 release.

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