Migrate HTTP client from httpx to httpx2 #10

Closed
opened 2026-09-10 06:15:46 +00:00 by agent-pi · 3 comments
Collaborator

Problem

The project convention (AGENTS.md) is to use httpx2 (pydantic's fork of httpx) for HTTP, never requests — but the codebase still depends on and imports httpx.

Affected files: src/yunjin/services/fetcher.py, src/yunjin/services/media_extractor.py, tests/test_fetcher.py, plus the httpx~=0.28.1 dependency in pyproject.toml.

Goal

Migrate all HTTP client usage to httpx2 and swap the dependency. API compatibility should be verified against the httpx2 docs during implementation rather than assumed.

## Problem The project convention (AGENTS.md) is to use **httpx2** (pydantic's fork of httpx) for HTTP, never requests — but the codebase still depends on and imports `httpx`. Affected files: `src/yunjin/services/fetcher.py`, `src/yunjin/services/media_extractor.py`, `tests/test_fetcher.py`, plus the `httpx~=0.28.1` dependency in `pyproject.toml`. ## Goal Migrate all HTTP client usage to httpx2 and swap the dependency. API compatibility should be verified against the httpx2 docs during implementation rather than assumed.
Author
Collaborator

Plan of attack

  1. Verify the httpx2 package name and API surface against its docs (import name, compatibility with existing httpx.get/AsyncClient call sites).
  2. Swap the dependency in pyproject.toml (~= pin), update the three affected files, regenerate uv.lock.
  3. Full local validation: ruff, ty, pytest.
## Plan of attack 1. Verify the httpx2 package name and API surface against its docs (import name, compatibility with existing `httpx.get`/`AsyncClient` call sites). 2. Swap the dependency in `pyproject.toml` (`~=` pin), update the three affected files, regenerate `uv.lock`. 3. Full local validation: ruff, ty, pytest.
Author
Collaborator

Findings (updated scope)

The issue body predates llm_aggregator.pysrc/yunjin/services/llm_aggregator.py and tests/test_aggregator.py also use httpx and are included (per the goal: migrate all HTTP client usage). Roadmap.md dependency summary will be updated too.

API compatibility verified against the installed httpx2 2.12.0 source (venv):

  • Import name: httpx2
  • get/post/head signatures accept headers, json, timeout, follow_redirects — identical to our call sites
  • TimeoutException, RequestError, HTTPStatusError, Response.raise_for_status()/.content/.text/.status_code all present
  • alias_httpx() exists but is for apps whose dependencies still import httpx — not needed here
  • Only yunjin depends on httpx in uv.lock, so it drops out cleanly

Execution

  1. Branch feat/issue-10-httpx2-migration
  2. Commit 1: swap imports in fetcher.py, media_extractor.py, llm_aggregator.py; update patch targets in test_fetcher.py, test_aggregator.py; httpx~=0.28.1httpx2~=2.12.0; uv sync -U --all-groups; regenerate pylock.toml same commit
  3. Commit 2: Roadmap.md dependency summary
  4. uv run nox → push → PR → ci-watch
## Findings (updated scope) The issue body predates `llm_aggregator.py` — **`src/yunjin/services/llm_aggregator.py` and `tests/test_aggregator.py` also use httpx** and are included (per the goal: migrate all HTTP client usage). `Roadmap.md` dependency summary will be updated too. API compatibility verified against the installed httpx2 2.12.0 source (venv): - Import name: `httpx2` - `get`/`post`/`head` signatures accept `headers`, `json`, `timeout`, `follow_redirects` — identical to our call sites - `TimeoutException`, `RequestError`, `HTTPStatusError`, `Response.raise_for_status()/.content/.text/.status_code` all present - `alias_httpx()` exists but is for apps whose dependencies still import httpx — not needed here - Only yunjin depends on httpx in `uv.lock`, so it drops out cleanly ## Execution 1. Branch `feat/issue-10-httpx2-migration` 2. Commit 1: swap imports in `fetcher.py`, `media_extractor.py`, `llm_aggregator.py`; update patch targets in `test_fetcher.py`, `test_aggregator.py`; `httpx~=0.28.1` → `httpx2~=2.12.0`; `uv sync -U --all-groups`; regenerate `pylock.toml` same commit 3. Commit 2: Roadmap.md dependency summary 4. `uv run nox` → push → PR → ci-watch
Author
Collaborator

Resolved by PR #15 (merged as 7201df4): the final Roadmap.md line went in via c07eef8; no leftover httpx references outside historical .superpowers/specs/ docs.

Resolved by PR #15 (merged as 7201df4): the final `Roadmap.md` line went in via c07eef8; no leftover httpx references outside historical `.superpowers/specs/` docs.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/yunjin#10
No description provided.