[TT-12193] Update error handling on webhook events when the event template has errors#6312
Conversation
…on template error
|
PR Description updated to latest commit (c5ab60e) |
|
API Changes --- prev.txt 2024-05-27 12:47:58.061924897 +0000
+++ current.txt 2024-05-27 12:47:55.173907251 +0000
@@ -10255,9 +10255,9 @@
func (w *WebHookHandler) Checksum(reqBody string) (string, error)
func (w *WebHookHandler) CreateBody(em config.EventMessage) (string, error)
- CreateBody will render the webhook event message template. If an error
- occurs, a partially rendered template will be returned alongside the error
- that occured.
+ CreateBody will render the webhook event message template and return it as
+ a string. If an error occurs, an empty string will be returned alongside an
+ error.
func (w *WebHookHandler) HandleEvent(em config.EventMessage)
HandleEvent will be fired when the event handler instance is found in an |
PR Review 🔍
Code feedback:
|
PR Code Suggestions ✨
|
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
|
/release to release-5.3 |
|
Working on it! Note that it can take a few minutes. |
…plate has errors (#6312) ### **User description** - Error log raised from Warning to Error, stops handling the event further - CreateBody adjusted to not return rendered template contents if error occurs ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Updated `CreateBody` method to return an empty string and error when template rendering fails, instead of a partially rendered template. - Changed log level from warning to error in `HandleEvent` method when a template rendering error occurs. - Added early return in `HandleEvent` to stop further processing if a template error is encountered. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix </strong></td><td><table> <tr> <td> <details> <summary><strong>event_handler_webhooks.go</strong><dd><code>Improve error handling in webhook event processing</code> </dd></summary> <hr> gateway/event_handler_webhooks.go <li>Updated <code>CreateBody</code> to return an empty string on error instead of a <br>partially rendered template.<br> <li> Changed log level from warning to error in <code>HandleEvent</code> when a template <br>rendering error occurs.<br> <li> Added early return in <code>HandleEvent</code> to stop processing on template <br>error.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6312/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+7/-4</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions Co-authored-by: Tit Petric <[email protected]> (cherry picked from commit f7cda28)
|
@titpetric Succesfully merged PR |
…vents when the event template has errors (#6312) [TT-12193] Update error handling on webhook events when the event template has errors (#6312) ### **User description** - Error log raised from Warning to Error, stops handling the event further - CreateBody adjusted to not return rendered template contents if error occurs ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Updated `CreateBody` method to return an empty string and error when template rendering fails, instead of a partially rendered template. - Changed log level from warning to error in `HandleEvent` method when a template rendering error occurs. - Added early return in `HandleEvent` to stop further processing if a template error is encountered. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix </strong></td><td><table> <tr> <td> <details> <summary><strong>event_handler_webhooks.go</strong><dd><code>Improve error handling in webhook event processing</code> </dd></summary> <hr> gateway/event_handler_webhooks.go <li>Updated <code>CreateBody</code> to return an empty string on error instead of a <br>partially rendered template.<br> <li> Changed log level from warning to error in <code>HandleEvent</code> when a template <br>rendering error occurs.<br> <li> Added early return in <code>HandleEvent</code> to stop processing on template <br>error.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6312/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+7/-4</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions Co-authored-by: Tit Petric <[email protected]>
…plate has errors (#6312) ### **User description** - Error log raised from Warning to Error, stops handling the event further - CreateBody adjusted to not return rendered template contents if error occurs ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Updated `CreateBody` method to return an empty string and error when template rendering fails, instead of a partially rendered template. - Changed log level from warning to error in `HandleEvent` method when a template rendering error occurs. - Added early return in `HandleEvent` to stop further processing if a template error is encountered. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix </strong></td><td><table> <tr> <td> <details> <summary><strong>event_handler_webhooks.go</strong><dd><code>Improve error handling in webhook event processing</code> </dd></summary> <hr> gateway/event_handler_webhooks.go <li>Updated <code>CreateBody</code> to return an empty string on error instead of a <br>partially rendered template.<br> <li> Changed log level from warning to error in <code>HandleEvent</code> when a template <br>rendering error occurs.<br> <li> Added early return in <code>HandleEvent</code> to stop processing on template <br>error.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6312/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+7/-4</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions Co-authored-by: Tit Petric <[email protected]>


User description
PR Type
Bug fix, Enhancement
Description
CreateBodymethod to return an empty string and error when template rendering fails, instead of a partially rendered template.HandleEventmethod when a template rendering error occurs.HandleEventto stop further processing if a template error is encountered.Changes walkthrough 📝
event_handler_webhooks.go
Improve error handling in webhook event processinggateway/event_handler_webhooks.go
CreateBodyto return an empty string on error instead of apartially rendered template.
HandleEventwhen a templaterendering error occurs.
HandleEventto stop processing on templateerror.