Skip to content

feat: Webhook Event System (closes #77)#771

Open
shaidshark wants to merge 3 commits intorohitdash08:mainfrom
shaidshark:feat/webhook-events
Open

feat: Webhook Event System (closes #77)#771
shaidshark wants to merge 3 commits intorohitdash08:mainfrom
shaidshark:feat/webhook-events

Conversation

@shaidshark
Copy link
Copy Markdown

Webhook Event System - Bounty

Implements signed webhook delivery with retry handling (closes #77).

Acceptance Criteria

Criteria Status
Signed delivery (HMAC-SHA256) Done
Retry and failure handling Done
Event types documented Done

What's Included

Core Service (packages/backend/app/services/webhooks/):

  • WebhookEndpoint model - register URLs per user with secrets
  • WebhookDelivery model - track attempts, status codes, retry scheduling
  • HMAC-SHA256 signed payloads (t=timestamp,v1=signature format)
  • Exponential backoff: 10s, 1m, 5m, 30m, 2h (max 5 attempts)

REST API (/webhooks/*):

  • POST /webhooks/endpoints - Register webhook URL
  • GET /webhooks/endpoints - List endpoints
  • DELETE /webhooks/endpoints/:id - Remove endpoint
  • GET /webhooks/endpoints/:id/deliveries - Delivery history
  • POST /webhooks/endpoints/:id/test - Send test event
  • GET /webhooks/event-types - List all event types

8 Event Types:
expense.created, expense.updated, expense.deleted, bill.created, bill.updated, bill.paid, budget.alert, user.registered

Tests: Full coverage - signature verification, event emission, retry on failure, API CRUD.

DB Schema: webhook_endpoints + webhook_deliveries tables with retry index.

shaidshark added 3 commits April 3, 2026 22:22
…itdash08#77)

- WebhookEndpoint model: register URLs per user with HMAC-SHA256 secrets
- WebhookDelivery model: track delivery attempts, status codes, retry scheduling
- 8 event types: expense/bill CRUD, budget alerts, user registration
- Exponential backoff retry: 10s, 1m, 5m, 30m, 2h (max 5 attempts)
- REST API: CRUD endpoints + test endpoint + delivery history
- HMAC-signed payloads with timestamp for verification
- Full test suite: unit + API tests
- DB schema migration included
- Fix retry logic: attempts <= MAX_RETRIES so 5th retry (2h) executes
- Add URL length validation (max 2048 chars) in endpoint creation
- Move timedelta and secrets imports to module top level
- Consistent retry condition in process_retries
- Block private IPs, localhost, link-local, cloud metadata (169.254.169.254)
- DNS resolution check via socket.getaddrinfo
- Description length validation (max 255 chars)
- Reduce URL exposure in logs (don't log full URL at INFO)
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.

Webhook Event System

1 participant