Improved webhook delivery failure logging#27032
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe changes adjust webhook delivery failure logging and add unit tests. The webhook trigger now logs failures at error level with a structured 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/services/webhooks/webhook-trigger.js (1)
94-94: Consider preserving the error stack trace for debugging.The structured log format is good for SLO alerting, but the current approach loses the error's stack trace which can be valuable for debugging delivery failures. Per the conventional pattern in the codebase (e.g.,
stripe/webhook-controller.jsline 102 useslogging.error(string, err)), you can pass the error object as a second argument.♻️ Suggested improvement to preserve stack trace
- logging.error(`[WEBHOOK_DELIVERY_FAILURE] url=${webhook.get('target_url') || 'unknown'} status=${err.statusCode || 'none'} error_code=${err.code || 'unknown'} message=${err.message || ''}`); + logging.error(`[WEBHOOK_DELIVERY_FAILURE] url=${webhook.get('target_url') || 'unknown'} status=${err.statusCode || 'none'} error_code=${err.code || 'unknown'} message=${err.message || ''}`, err);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/server/services/webhooks/webhook-trigger.js` at line 94, The webhook delivery failure log currently formats key fields but drops the error stack; update the logging.error call in webhook-trigger.js (the line that logs `[WEBHOOK_DELIVERY_FAILURE] url=${webhook.get('target_url') ...}` and references the err object) to pass the err object as a second argument (e.g., logging.error(<formatted message>, err)) so the structured message is preserved while the error stack/metadata from err is also recorded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/core/server/services/webhooks/webhook-trigger.js`:
- Line 94: The webhook delivery failure log currently formats key fields but
drops the error stack; update the logging.error call in webhook-trigger.js (the
line that logs `[WEBHOOK_DELIVERY_FAILURE] url=${webhook.get('target_url') ...}`
and references the err object) to pass the err object as a second argument
(e.g., logging.error(<formatted message>, err)) so the structured message is
preserved while the error stack/metadata from err is also recorded.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 02125a61-e781-4bd8-ac01-da7a1b02b4ea
📒 Files selected for processing (2)
ghost/core/core/server/services/webhooks/webhook-trigger.jsghost/core/test/unit/server/services/webhooks/trigger.test.js
Webhook delivery errors were logged at warn level with unstructured messages, making them invisible to error-level monitoring. Promoted to error level with a structured [WEBHOOK_DELIVERY_FAILURE] prefix for easy log filtering.
501ea90 to
80ceb93
Compare
|



ref https://linear.app/ghost/issue/ONC-1609/
warntoerrorlevel so they surface in error-level monitoring[WEBHOOK_DELIVERY_FAILURE]prefix withurl,status,error_code, andmessagefields for easy SLO alerting