Skip to content

refactor(alerts): drop fetch from AlertRuntime, use the runtime HttpClient - #1261

Merged
Makisuo merged 1 commit into
mainfrom
claude/nervous-liskov-efb755
Oct 5, 2026
Merged

Makisuo merged 1 commit into
mainfrom
claude/nervous-liskov-efb755

refactor(alerts): drop fetch from AlertRuntime, use the runtime HttpC…

1b9274f
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Oct 5, 2026 in 4m 32s

Confidence 4/5 · No issues found

🟢 Confidence 4/5 · likely safe to merge
Every production hunk is a semantics-preserving swap of the raw fetch for the ambient client, and all call sites and fake-fetch wirings were updated together.
quality 100/100 · no findings · tests covered · risk low · 2/3 new units observable

Removes the raw fetch from AlertRuntime and routes alert delivery, Telegram verification and the PagerDuty key check through the runtime HttpClient (fake wire injected as FetchHttpClient.Fetch). The refactor is equivalent in behavior; nothing here needs changing before merge.

  • dispatchDelivery and TransportRuntime drop fetchFn; delivery uses the ambient HttpClient
  • telegramGet replaces raw fetch and suppresses the client span for the token-bearing URL
  • verifyPagerDutyRoutingKey posts via HttpClientRequest/HttpClient.execute
  • AlertRuntimeApi loses fetch; tests inject FetchHttpClient.Fetch instead
What was checked
  • telegramGet keeps old semantics: ok from status >= 200 && < 300 (telegram.ts:157) equals fetch's response.ok, and the timeout still wraps each discovery call
  • HttpClient.TracerDisabledWhen provided around the call is the repo's established pattern (apps/cli/src/commands/server.ts:499, lib/safe-fetch/src/index.ts:235, runTransport.ts:139), so the bot…
  • Body reads stay in the request continuation (telegram.ts:155, pagerduty.ts:108), matching ElectricClient.ts:271 and the CLI, so no scope-closed read
Observability coverage: 2 of 3 changes observable
Change Kind Observable Evidence
Telegram Bot API GET (getMe/getChat/getUpdates) via HttpClient outbound call no Client span deliberately suppressed via HttpClient.TracerDisabledWhen at telegram.ts:163 — bot token is in the URL path
PagerDuty routing-key verification POST via HttpClient outbound call yes pagerduty.ts:91-101 now emits the client span for the fixed vendor host (routing key is in the body)
Alert delivery provider sends via HttpClient outbound call yes runTransport.ts:133 keeps the AlertDelivery.http client span with peer.service; only the per-send FetchHttpClient.Fetch override was removed

1b9274f · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.