feat: per-subscription webhook retry policy override#584
Merged
greatest0fallt1me merged 1 commit intoJun 29, 2026
Merged
Conversation
|
@ayomidearegbeshola29-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- Add RetryPolicy interface and DEFAULT_RETRY_POLICY constant to webhook.types.ts - Add validateRetryPolicy() for input validation at API boundary (maxRetries 0-10, baseDelayMs 100-60000) - Add getEffectiveRetryPolicy() to merge subscription overrides with defaults - Add calculateBackoff() for exponential backoff calculation - Update dispatcher to use subscription-specific retry policy - Add PATCH /api/webhooks/:developerId/retry-policy endpoint - Include retryPolicy in webhook registration and GET responses - Update webhook monitor to include retry policy in subscription stats - Add comprehensive unit and integration tests
db2ff26 to
bbd4ca6
Compare
4 tasks
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.
Webhook Retry Policy Override
Feature Description
This implementation adds per-subscription override capability for webhook retry policies. Each webhook subscription can now configure custom retry behavior instead of relying solely on the default retry policy.
API Changes
Registration Endpoint
POST /api/webhooks
The registration endpoint now accepts an optional
retryPolicyfield:{ "developerId": "dev-123", "url": "https://example.com/webhook", "events": ["new_api_call", "settlement_completed"], "secret": "optional-secret", "retryPolicy": { "maxRetries": 5, "baseDelayMs": 1000 } }Retry Policy Update Endpoint
PATCH /api/webhooks/:developerId/retry-policy
Updates the retry policy for an existing subscription:
{ "retryPolicy": { "maxRetries": 3, "baseDelayMs": 500 } }Response:
{ "message": "Webhook retry policy updated successfully.", "developerId": "dev-123", "url": "https://example.com/webhook", "events": ["new_api_call"], "retryPolicy": { "maxRetries": 3, "baseDelayMs": 500 } // Note: secrets are never exposed in responses }Get Webhook Config
GET /api/webhooks/:developerId
Now includes the
retryPolicyfield in the response when configured:{ "developerId": "dev-123", "url": "https://example.com/webhook", "events": ["new_api_call"], "retryPolicy": { "maxRetries": 3, "baseDelayMs": 500 } }Validation Rules
The
retryPolicyobject is validated at the API boundary with the following constraints:maxRetriesbaseDelayMsBoth fields are optional. Unspecified fields use default values:
maxRetries: 5baseDelayMs: 1000msBehavior
Exponential Backoff
The dispatcher uses exponential backoff with the configured base delay:
Override vs Default
When a subscription has no
retryPolicyconfigured or when fields are omitted, the default values are used:Monitor Integration
The webhook monitor (
/api/admin/webhooks/monitor) now includesretryPolicyinformation in the subscription statistics when an override is configured.Security Considerations
logger.audit()with correlation IDsTest Coverage
validateRetryPolicy()covering all validation edge casesgetEffectiveRetryPolicy()with partial and full overridescalculateBackoff()exponential backoff calculationcloses #518