Skip to content

#125 feat: adopt notifier-client 0.4.0; the service moves to httpx2 - #126

Merged
gregoryfoster merged 1 commit into
mainfrom
125-httpx2
Nov 17, 2026
Merged

gregoryfoster merged 1 commit into
mainfrom
125-httpx2

Conversation

@gregoryfoster

Copy link
Copy Markdown
Member

Closes #125

Adopts notifier-client v0.4.0 (003693d). Per the operator's decision, the whole process moves to httpx2: alerting, heartbeat, drift and scripts/rotate_key.py. httpx leaves the runtime dependencies; only respx (dev) still pulls it in. uv export --no-dev has no httpx or httpcore.

Red first

With the SDK on 0.4.0, no alias, and src/ unchanged, the five unreachable-notifier cases raise httpx2.ConnectError at httpx2's own transport (new unreachable fixture):

FAILED tests/core/test_alerting.py::TestCheckEndpoint::test_an_unreachable_notifier_is_unavailable_not_mismatched
FAILED tests/core/test_alerting.py::TestCheckTemplate::test_an_unreachable_preview_is_unavailable
FAILED tests/core/test_alerting.py::TestKnownChannelIds::test_an_unreachable_notifier_is_unavailable
FAILED tests/core/test_alerting.py::TestRedeliver::test_a_network_failure_is_unavailable
FAILED tests/core/test_alerting.py::TestSend::test_a_network_failure_is_unavailable
E   httpx2.ConnectError: refused        (×5: escaped all five clauses)
======================= 5 failed, 57 deselected =======================

Why not with the alias: alias_httpx() rebinds sys.modules["httpx"] process-wide. Under it, alerting.py's old import httpx is httpx2, so the old clauses pass. The alias hides exactly this bug. So the red ran without it, and these guards keep it fixed:

  • tests/ci/test_http_stack.py: an AST walk finds no httpx/httpcore import in src/, scripts/ or alembic/. A fresh interpreter, with no alias, imports every src module and loads neither.
  • The five cases stay at the transport level (unreachable), independent of respx and the alias.

Red with the alias in place (8 failed): the guards above, plus three heartbeat tests. One of those is a real leak.

Found beyond the brief: hc-ping key in the journal

The brief said nothing attaches to the httpx logger. heartbeat._RedactKey does: it masks the healthchecks.io ping key in the HTTP Request: POST <url> line. httpx2 logs that line on httpx2, so after a plain swap the filter masked nothing. test_the_key_never_reaches_the_request_log failed on KEY not in message. The filter now sits on REQUEST_LOGGER = "httpx2".

Trust store: certifi stays

httpx2 verifies against the OS store, not certifi. On this host the OS store still trusts emSign C1 and ECC C3, which certifi 2026.10.23 dropped (CannObserv/provisioner#77). Moving would widen trust silently.

  • src/core/tls.trusted(): ssl.create_default_context(cafile=certifi.where()), cached. httpx2's verify= takes an SSLContext (checked in httpx2/_config.py).
  • Every httpx2 client or request call under src/ and scripts/ passes verify=trusted(): heartbeat ×2, drift, rotate_key.
  • tests/ci/test_trust_store.py (certifi ≥ 2026.10.19: venvs still trust emSign ECC Root CA - G3 (eMudhra compromise) #58) now also checks:
    • trusted() holds exactly certifi's roots (DER sets equal) and verifies hostnames;
    • every httpx2.<Client|AsyncClient|get|post|…>(…) call site has verify=trusted(), with a found-something floor;
    • no from httpx2 import Client that would hide a site from the walk.
  • certifi>=2026.10.23,<2027 is declared, with a SECURITY_FLOORS entry: 2026.10.19, PYSEC-2026-4320.
  • Checked live: trusted() completes TLS to hc-ping.com and api.github.com.
  • One behaviour change: SSL_CERT_FILE no longer applies to our clients. No unit sets it.
  • The SDK's own client can't be configured. It stays on the OS store, and that's moot while notifier is http:// over the tailnet.

Tests

  • tests/conftest.py: httpx2.alias_httpx() comes before any import. pytest_plugins = ["respx.plugin"], and -p no:respx is in addopts. A late alias raises rather than splitting the stack.
  • Test modules name httpx2 explicitly; respx is the only thing importing httpx.
  • 1986 passed, 6 skipped, coverage 98.68%. Collected 1992, against main's 1926: +66, all new guard cases. uv audit: no known vulnerabilities (52 packages).

Docs

  • AGENTS.md: how tests reach notifier (the alias, the guard), and a row for src/core/tls.py.
  • docs/reference/monitors.md § At least once: 0.4.0's 60 s channel limit can double a redelivery. Accepted, not fixed. Over the last 30 days, all 150 dispatches were succeeded.

Not done here

  • No note on notifier that its CHANGELOG's notifier#141 cite should probably be #144. That waits for operator consent, as the brief says.
  • Not checked: whether any co-status channel is chime:// (gone in apprise 2.2.0) or Telegram (now gets Markdown). Both are server-side, already live, and outside this PR.

Deploy after merge: dev → live through scripts/deploy.sh, then the brief's ping checks.

🤖 Generated with Claude Code

notifier-client 0.4.0 sends through httpx2 and re-raises its exceptions,
so alerting's five `except httpx.TransportError` clauses stopped matching
an unreachable notifier. The whole process now runs httpx2: alerting,
heartbeat, drift and rotate_key. httpx leaves the runtime dependencies;
only respx (dev) still needs it.

- Tests: httpx2.alias_httpx() at the top of tests/conftest.py, respx's
  plugin loaded there (-p no:respx). The five unreachable cases raise
  httpx2.ConnectError at httpx2's transport (`unreachable` fixture);
  without the alias they failed on the old clauses.
- The hc-ping key redaction moves to the `httpx2` logger: on `httpx` it
  masked nothing, and the key reached the request log.
- Trust store: httpx2 defaults to the OS store, which still trusts emSign
  C1 and ECC C3. src/core/tls.trusted() keeps certifi's bundle alone;
  every httpx2 call passes verify=trusted(), and test_trust_store.py
  checks the context and every call site. certifi declared, floored.
- tests/ci/test_http_stack.py: no httpx/httpcore import in src/, scripts/,
  alembic/, nor loaded by a fresh interpreter importing all of src.
- monitors.md: 0.4.0's 60 s channel limit can double a redelivery;
  accepted.

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