Repository navigation
Send an alert webhook when a connector keeps failing - #976
Open
rangarajan19 wants to merge 1 commit into
Open
rangarajan19 wants to merge 1 commit into
rangarajan19 wants to merge 1 commit into
Conversation
Detects a connector failing repeatedly (configurable threshold over a sliding window) and dispatches a signed webhook or Slack message, with a cooldown so a sustained outage sends one alert, not one per call. - New AlertsModule: per-org webhook config (OrgSettings), encrypted secret shown once, GET/PUT/DELETE + POST .../test admin endpoints. - Detection hooks into AuditService.logInvocation ahead of the repeat-failure dedup check, so a fast-repeating identical failure still counts toward the threshold. Fire-and-forget; never affects the MCP call path. - Sliding-window counter and cooldown via Redis (incr/expire), with an in-memory fallback when Redis isn't configured. - Dispatch is HMAC-signed and SSRF-guarded; the webhook URL ignores the env/DB connector allowlists so a workspace can't point it at a host allowed for an unrelated reason (ssrf.util.ts/outbound-http.ts gain an opt-in skipAllowlists flag for this). - Docs: new section in docs/operations/observability.md. Relates to HelpCode-ai#857.
| : JSON.stringify(payload); | ||
| const timestamp = Math.floor(Date.now() / 1000).toString(); | ||
| const signature = createHmac('sha256', secret) | ||
| .update(`${timestamp}.${body}`) |
Contributor
Author
|
Hi @keysersoft, PR 1 for the connector-failure alert webhook is up here. While working on it I noticed #857 (and the whole #840-867 range, including the October Challenge issue #846) is no longer accessible — just a 404, not sure if that was intentional. Do you still want this feature added, or has priority changed? Happy to keep going as-is if so. |
Contributor
Author
|
Hi @mirkopoloni , do we need this, because the issue is not showing , should I delete this or ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backend half of #857 (PR 1 of the planned split, UI card to follow in PR 2): detects a connector failing repeatedly within a sliding window and dispatches a signed webhook (or Slack message), with a cooldown so a sustained outage sends one alert, not one per call.
Changes
AlertsModule: per-organization webhook config stored viaOrgSettingsService, signing secret generated server-side and encrypted (AES-256-GCM, AAD-bound to the org), shown once. Admin endpoints:GET/PUT/DELETE+POST .../testat/api/admin/settings/alert-webhook.AuditService.logInvocation, firing before the repeat-failure dedup check added since this plan was discussed, so a fast-repeating identical failure (the common case for a real outage) still counts toward the threshold instead of being silently skipped. Fire-and-forget: a dispatch failure is caught and logged, never affects the MCP call path.RedisService(incr/expire), with an in-memory fallback when Redis isn't configured. Dispatch fires only when the counter hits the threshold exactly, and the cooldown key is written before the dispatch goes out, so two failures crossing the threshold at the same moment can't both fire.X-AnythingMCP-Signature) and goes through the existing SSRF-guarded outbound path. The webhook URL deliberately ignores both the env (SSRF_ALLOWED_HOSTS) and the admin-editable DB allowlist —ssrf.util.ts/outbound-http.tsgain an opt-inskipAllowlistsoption for this, since those allowlists exist for connectors to reach a specific internal host for their own reason, and a webhook target must not inherit that trust.docs/operations/observability.md— payload shape, headers, a Node verification snippet.PR 2 (the Alerts card on
/settings/admin) will follow once this is reviewed.Testing
npm testinpackages/backend)New:
src/alerts/alerts.service.spec.ts,src/alerts/alerts.controller.spec.ts, and additions tosrc/audit/audit.service.spec.tscovering threshold→one dispatch, cooldown suppressing the next, cross-org isolation, signature verification, dispatch errors never affectinglogInvocation, SSRF (private IP and the cloud metadata address rejected even when allowlisted), and non-admin → 403.Ran from
packages/backend:All clean; 747 tests passing in the scoped run above (the files this PR touches and everything that depends on them).
Related Issues
Relates to #857