Skip to content

#420 feat: adopt notifier-client v0.4.0; the whole process moves to httpx2 - #424

Merged
gregoryfoster merged 3 commits into
mainfrom
feat/420-httpx2
Nov 17, 2026
Merged

gregoryfoster merged 3 commits into
mainfrom
feat/420-httpx2

Conversation

@gregoryfoster

Copy link
Copy Markdown
Member

Closes #420

Adopts notifier-client v0.4.0 (bcf042eb). Following the coordinator's brief and co-status's precedent (CannObserv/status#125, PR CannObserv/status#126), the whole process moves from httpx to httpx2. httpx and httpcore leave uv.lock, and no alias is needed: there is no respx here (brief §1).

Red first

1. SDK bumped only, code unchanged (tool.uv.sources → v0.4.0, notifier-client>=0.4.0,<1). The fakes now raise httpx2.ConnectError, and each fail-open case asserts which branch it hit:

FAILED tests/unit/scripts/test_notify_unit_failure.py::test_main_fails_open[unreachable]
FAILED tests/unit/scripts/test_notify_unit_failure.py::test_main_real_sdk_unreachable_notifier_fails_open
FAILED tests/unit/scripts/test_archive_age_check.py::test_breach_that_reaches_no_channel_exits_1[unreachable]
FAILED tests/unit/scripts/test_archive_age_check.py::test_real_sdk_unreachable_notifier
WARNING  notify_unit_failure:notify_unit_failure.py:240 notifier dispatch for audit-archive.service failed unexpectedly; the journal line stands
httpcore2.ConnectError: All connection attempts failed
httpx2.ConnectError: All connection attempts failed
WARNING  archive_age_check:archive_age_check.py:166 archive-age dispatch failed unexpectedly
4 failed, 63 passed

2. Logger pins on the old names. A real httpx2 request under LOG_LEVEL=DEBUG wrote the address to stdout at INFO:

FAILED tests/unit/core/test_logging.py::TestPiiPinnedLoggers::test_address_bearing_httpx2_record_is_suppressed
FAILED tests/unit/core/test_logging.py::TestPiiPinnedLoggers::test_pin_survives_log_level_debug
FAILED tests/unit/core/test_logging.py::TestPiiPinnedLoggers::test_a_real_httpx2_request_logs_nothing_under_debug
E  AssertionError: address content reached the log: '{"level": "INFO", "logger": "httpx2", "message": "HTTP Request: GET http://localhost:4400/parse?address=4711+Yonge+Street \"HTTP/1.1 200 OK\"", ...}'
3 failed, 2 passed

3. Guards, before any site moved:

tests/ci/test_http_stack.py: 10 failed, 139 passed
  9 × test_nothing_that_runs_imports_httpx  (registry, usps_client, google_client, _rate_limit,
      libpostal_client, notify_unit_failure, archive_age_check, status_checkin, patching_recovery_check)
  test_the_service_loads_no_httpx_at_run_time
tests/ci/test_trust_store.py (with tls.py present, sites not yet moved):
  FAILED test_every_client_was_found - assert 0 >= 4

Green

  • Sites (brief §4): registry.py, usps_client.py, google_client.py, _rate_limit.py, libpostal_client.py, and in infra/: notify_unit_failure.py, archive_age_check.py, status_checkin.py, patching_recovery_check.py. All are renames; behaviour is unchanged apart from TLS (below).
  • Logging: PINNED_LOGGER_LEVELS and core/log_config.json now pin httpx2 and httpcore2, replacing the old names. The old names are dropped: nothing in the process loads httpx, and test_http_stack.py keeps it that way.
  • TLS: core/tls.trusted(), modeled on status's src/core/tls.py, is a cached ssl.create_default_context(cafile=certifi.where()). All 4 client sites pass verify=trusted(), the plain-http ones too: registry (USPS + Google), libpostal, status_checkin, patching_recovery_check.
  • Deps: httpx2>=2.16.2,<3, certifi>=2026.10.19,<2027 (now explicit), notifier-client>=0.4.0,<1. httpx is removed from runtime and dev.
  • Guards: tests/ci/test_http_stack.py and tests/ci/test_trust_store.py.
    • http-stack: an AST walk over src/ infra/ scripts/ alembic/, plus a fresh interpreter importing every src and infra module. That includes notifier_client, and the test asserts it was imported.
    • trust-store: G3 is absent from certifi; both trusted() copies hold exactly certifi's roots and check hostnames; every httpx2.<call> site passes verify=trusted(), imported from a tls module; floor ≥ 4; no from httpx2 import Client.
  • Tests ported by rename: MockTransport, AsyncMock(spec=httpx2.AsyncClient), MagicMock(spec=httpx2.Response), and the exception fakes. The 13 TestClient files needed no change: Starlette now picks httpx2, and its "Using httpx … is deprecated" warning is gone from the run (3 → 2 warnings).

uv.lock delta

Package Before After
httpx 0.28.1 removed
httpcore 1.0.9 removed
httpx2 — 2.16.2
httpcore2 — 2.16.2
truststore — 0.10.5 (httpx2 dep; bypassed by verify=trusted())
httpx2-jsfetch — 1.0 (sys_platform == 'emscripten' only; not installed)
certifi 2026.10.19 (transitive) 2026.10.19 (declared)
notifier-client 0.3.2 (8e7c020b) 0.4.0 (bcf042eb)

No dependency still needs httpx, so CannObserv/status#127's alias fallback isn't needed.

Tests

main a758d08 this branch d8bc2f1
full suite 2751 passed, 5 skipped 2916 passed, 5 skipped (+165, nearly all parametrized guard cases)
coverage 96.43% 96.42–96.44%

About the coverage range: the files this PR touches miss the same lines as on main, shifted by the inserted lines. The ±1-line wobble is routers/admin/queries/dashboard.py:81, a return inside a gathered coroutine. It's timing-dependent and untouched here: one branch run on identical code scored 96.44%.

Also passing: uv run pre-commit run --all-files, bash scripts/pre-ship.sh (2830 passed, 5 skipped, 86 deselected, plus JS 8/8), uv audit --frozen (no known vulnerabilities, 85 packages), uv lock --check.

Found beyond the brief

  • The existing fail-open tests couldn't go red. test_main_fails_open asserted only "the journal line stands", which both the expected and the unexpected branch log. Swapping the fake to httpx2.ConnectError alone would have stayed green. Each case now asserts whether "failed unexpectedly" appears.
  • The two real-SDK tests passed on the wrong branch. Their docstrings say "the SDK's own error type is caught", but they asserted only "ConnectError" in caplog.text, and the unexpected path's traceback contains that string too. Both now also assert unexpectedly is absent. They are the only tests that drive the real 0.4.0 SDK, and they went red in step 1.
  • infra/tls.py, a twin of core/tls.py. The patching knob runs infra/patching_recovery_check.py with no PYTHONPATH (.skills/patching-hosts), so it can't import address_validator. The infra scripts take trusted() from a sibling module, as they already do journal_logging. The trust-store test parametrizes over both and requires each call site to import trusted from one of the two.
  • SSL_CERT_FILE no longer applies to our clients (an explicit context overrides it). No unit sets it, and the prod env file has no SSL_CERT key (checked by count, not printed).
  • The LOGGING.md correction reaches further than :126: the USPS token call is the other POST. That body carries the client secret, which httpx2 doesn't log either.

Docs

LOGGING.md (pinned rows, httpx2.RequestError, the USPS GET correction), SENSITIVE-AREAS.md (logging, libpostal and chain-provider rows; new core/tls.py row), SENSITIVE-AREAS-INFRA.md (SDK except clauses, infra/tls.py), ARCHITECTURE.md:78 + core/tls.py, VALIDATION-PROVIDERS.md:270, README.md, CHANGELOG.md. DEPENDENCY-POLICY.md has no per-package table, so it has no rows to add. No PIPELINE_CODE_VERSION bump; models.py and openapi.json are unchanged.

Deploy (not done; needs approval)

A runtime change: in the main checkout, uv sync and then sudo systemctl restart address-validator, outside the patching quiet ranges. Verify per brief §7: health 200, no httpx2/httpcore2 INFO record in the journal since the restart, and one real USPS /api/v2/validate over the certifi context. The first runs of archive-age-check, unit-failure@ and the backup's status_checkin on 0.4.0 remain verification debt.

🤖 Generated with Claude Code

gregoryfoster and others added 3 commits November 17, 2026 18:08
… httpx2

notifier-client 0.4.0 re-raises httpx2's exceptions, so the
`except httpx.HTTPError` clauses in notify_unit_failure.py and
archive_age_check.py stopped matching: an unreachable notifier fell
through to the last-resort handler and was logged as "unexpected".

- Every httpx site moves to httpx2 (registry, usps/google clients,
  _rate_limit, libpostal_client, the four infra scripts); httpx and
  httpcore leave uv.lock.
- PII-guard logger pins move to httpx2/httpcore2, the names httpx2
  logs on (libpostal and USPS both GET with the address in the query).
- httpx2 defaults to the OS trust store; every client passes
  verify=trusted(), a certifi-only context (core/tls.py, and
  infra/tls.py for scripts with no PYTHONPATH). certifi declared.
- Guards: tests/ci/test_http_stack.py (AST walk + fresh interpreter),
  tests/ci/test_trust_store.py (certifi roots, hostname checks, every
  call site). Fail-open tests now assert which branch they hit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LOGGING.md: pinned rows on httpx2/httpcore2; USPS's address call is a
  GET with the address in the query string, not a POST.
- SENSITIVE-AREAS(-INFRA).md: logging and libpostal rows, rows for
  core/tls.py, infra/tls.py and the SDK except clauses.
- ARCHITECTURE.md, VALIDATION-PROVIDERS.md, README.md, CHANGELOG.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Adopt notifier-client v0.4.0: httpx → httpx2 silently breaks except clauses around SDK calls

1 participant