Repository navigation
refactor(alerts): drop fetch from AlertRuntime, use the runtime HttpClient - #1261
Conversation
…lient Alert delivery already runs on the HttpClient from the app runtime, but AlertRuntime still carried a raw `fetch` that dispatchDelivery used only to override FetchHttpClient.Fetch per send, and that the save-time checks (Telegram chat discovery, Telegram credential check, PagerDuty routing key check) called directly. - Remove `fetch` from AlertRuntimeApi and `fetchFn` from dispatchDelivery / TransportRuntime (NotificationDispatcher passed globalThis.fetch too). - fetchTelegramChats, verifyTelegramCredentials and verifyPagerDutyRoutingKey require HttpClient; AlertDestinationsService provides the client it acquires in its constructor. Telegram calls disable the client span because the bot token is in the URL path. - Tests provide their fake wire as FetchHttpClient.Fetch.
Maple review🟢 Confidence 4/5 · likely safe to merge Removes the raw
What was checked
Observability coverage: 2 of 3 changes observable
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (17)
💤 Files with no reviewable changes (6)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAlert delivery and destination verification now use the Effect ChangesAlerts HTTP client migration
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to This refactor moves alert HTTP calls onto the shared HttpClient service without changing destinations or result handling. No concrete merge-blocking risk remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The reviewed paths preserve administrator checks, tenant-scoped storage, outbound URL protection, and token-safe tracing. No introduced security issue was established. The shared dependency change has limited residual uncertainty around consumers and runtime configurations outside the reviewed paths. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Follow-up to #1257. Alert delivery already runs on the
HttpClientfrom the app runtime, butAlertRuntimestill exposed a rawfetch. This removes it.AlertRuntimeApilosesfetch;dispatchDelivery/TransportRuntimelosefetchFn, andrunTransportno longer overridesFetchHttpClient.Fetchper send.NotificationDispatcherwas also passingglobalThis.fetchand is updated.fetchTelegramChats), the Telegram credential check (verifyTelegramCredentials) and the PagerDuty routing-key check (verifyPagerDutyRoutingKey) now requireHttpClient.HttpClient.AlertDestinationsServiceprovides the client it acquires in its constructor viaEffect.provideService.AlertRuntimeoverrides or thedispatchDeliveryargument now provide it asFetchHttpClient.Fetch.AlertsService.test.tskeeps afetchkey onmakeLayer's overrides so its call sites stay unchanged; it is wired toFetchHttpClient.Fetch.Reviewer notes
HttpClient.TracerDisabledWhentoconstTrue: the bot token is in the URL path and the client span recordsurl.full. Same reasoning as delivery inrunTransport.fetchas a bare function.Verification
tsc --noEmitclean inpackages/backendandapps/api; effect lint clean on the changed files.vitest runonAlertsService,AlertRulesService,AlertDeliveryDispatch*,delivery/**(171 tests) andapps/apialerts.http+alchemy-provider.integration(18 tests): all pass.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit