Skip to content

[TT-12323] fix panic when webhook handler is disabled#6334

Merged
jeffy-mathew merged 1 commit into
masterfrom
fix/TT-12323/panic-on-disabled-webhook-trigger
Jun 11, 2024
Merged

[TT-12323] fix panic when webhook handler is disabled#6334
jeffy-mathew merged 1 commit into
masterfrom
fix/TT-12323/panic-on-disabled-webhook-trigger

Conversation

@jeffy-mathew

@jeffy-mathew jeffy-mathew commented Jun 10, 2024

Copy link
Copy Markdown
Contributor

User description

Description

fix panic when webhook handler is disabled

Related Issue

https://tyktech.atlassian.net/browse/TT-12323

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)

Checklist

  • I ensured that the documentation is up to date
  • I explained why this PR updates go.mod in detail with reasoning why it's required
  • I would like a code coverage CI quality gate exception and have explained why

PR Type

Bug fix, Tests


Description

  • Added error handling for when the webhook handler is disabled by introducing a new error variable ErrEventHandlerDisabled.
  • Modified the Init method in WebHookHandler to return the new error when the webhook is disabled.
  • Updated the corresponding test to check for the ErrEventHandlerDisabled error instead of no error.

Changes walkthrough 📝

Relevant files
Bug fix
event_handler_webhooks.go
Add error handling for disabled webhook handler                   

gateway/event_handler_webhooks.go

  • Added error handling for disabled webhook handler.
  • Introduced ErrEventHandlerDisabled error variable.
  • Modified Init method to return ErrEventHandlerDisabled when webhook is
    disabled.
  • +6/-1     
    Tests
    event_handler_webhooks_test.go
    Update test for disabled webhook handler error                     

    gateway/event_handler_webhooks_test.go

    • Updated test to check for ErrEventHandlerDisabled error.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5]

    2

    🧪 Relevant tests

    Yes

    🔒 Security concerns

    No

    ⚡ Key issues to review

    None

    @github-actions

    github-actions Bot commented Jun 10, 2024

    Copy link
    Copy Markdown
    Contributor

    API Changes

    --- prev.txt	2024-06-10 14:00:03.588701478 +0000
    +++ current.txt	2024-06-10 14:00:00.288711149 +0000
    @@ -7286,6 +7286,10 @@
         a future version.
     
     var (
    +	// ErrEventHandlerDisabled is returned when the event handler is disabled.
    +	ErrEventHandlerDisabled = errors.New("event handler disabled")
    +)
    +var (
     	ErrPoliciesFetchFailed = errors.New("fetch policies request login failure")
     )
     var (

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add nil check for configuration to prevent potential panics

    It's recommended to add a check for the configuration being nil before accessing its
    properties. This can prevent potential panics due to nil dereference.

    gateway/event_handler_webhooks.go [65]

    -if w.conf.Disabled {
    +if w.conf != nil && w.conf.Disabled {
     
    Suggestion importance[1-10]: 9

    Why: Adding a nil check for the configuration is important to prevent potential runtime panics, which can lead to more robust and stable code.

    9
    Enhancement
    Add logging for errors to enhance debugging and error tracking

    Consider logging the error before returning it to provide more debugging information about
    why the event handler was disabled.

    gateway/event_handler_webhooks.go [68]

    +log.Error("Event handler disabled due to configuration: ", w.conf.Name)
     return ErrEventHandlerDisabled
     
    Suggestion importance[1-10]: 8

    Why: Adding logging before returning the error can provide valuable debugging information and improve error tracking, making it a useful enhancement.

    8
    Improve error handling by adding more context or using a custom error type

    Consider using a more specific error type or wrapping the error with additional context.
    Using errors.New directly with a generic message can make it harder to handle errors
    programmatically elsewhere in the code. You might want to create a custom error type or
    use fmt.Errorf to add more context.

    gateway/event_handler_webhooks.go [40]

    -ErrEventHandlerDisabled = errors.New("event handler disabled")
    +ErrEventHandlerDisabled = fmt.Errorf("event handler disabled: %w", someContextVariable)
     
    Suggestion importance[1-10]: 7

    Why: The suggestion to use a more specific error type or add context to the error message can improve error handling and debugging. However, it is not crucial and the current implementation is functional.

    7
    Enhance test to check for unintended modifications in handler configuration

    To ensure the test is robust, consider adding a check to confirm that the handler's
    configuration is not modified when the handler is disabled. This can help catch unintended
    side effects in the configuration logic.

    gateway/event_handler_webhooks_test.go [55]

     assert.True(t, h.conf.Disabled)
    +assert.Equal(t, expectedConfig, h.conf, "Handler configuration should not be modified when disabled")
     
    Suggestion importance[1-10]: 6

    Why: The suggestion enhances the test by ensuring that the configuration remains unchanged, which can help catch unintended side effects. However, it is a minor improvement and not critical.

    6

    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-12323/panic-on-disabled-webhook-trigger branch from 963c85e to cad78ca Compare June 10, 2024 13:59
    @sonarqubecloud

    Copy link
    Copy Markdown

    @jeffy-mathew
    jeffy-mathew merged commit 3e5963c into master Jun 11, 2024
    @jeffy-mathew
    jeffy-mathew deleted the fix/TT-12323/panic-on-disabled-webhook-trigger branch June 11, 2024 09:12
    @jeffy-mathew

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.4

    @jeffy-mathew

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.4.0

    @tykbot

    tykbot Bot commented Jun 11, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    tykbot Bot pushed a commit that referenced this pull request Jun 11, 2024
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
     fix panic when webhook handler is disabled
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-12323
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added error handling for when the webhook handler is disabled by
    introducing a new error variable `ErrEventHandlerDisabled`.
    - Modified the `Init` method in `WebHookHandler` to return the new error
    when the webhook is disabled.
    - Updated the corresponding test to check for the
    `ErrEventHandlerDisabled` error instead of no error.
    
    
    ___
    
    
    
    ### **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>Add error
    handling for disabled webhook handler</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks.go
    <li>Added error handling for disabled webhook handler.<br> <li>
    Introduced <code>ErrEventHandlerDisabled</code> error variable.<br> <li>
    Modified <code>Init</code> method to return
    <code>ErrEventHandlerDisabled</code> when webhook is <br>disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+6/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    
    <summary><strong>event_handler_webhooks_test.go</strong><dd><code>Update
    test for disabled webhook handler error</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks_test.go
    - Updated test to check for `ErrEventHandlerDisabled` error.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-1a2f8d6ab4443031b0f8486809453f6389291a6f625745fe8c65ac5cdb0e9621">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </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
    
    (cherry picked from commit 3e5963c)
    @tykbot

    tykbot Bot commented Jun 11, 2024

    Copy link
    Copy Markdown

    @jeffy-mathew Succesfully merged PR

    @tykbot

    tykbot Bot commented Jun 11, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    tykbot Bot pushed a commit that referenced this pull request Jun 11, 2024
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
     fix panic when webhook handler is disabled
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-12323
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added error handling for when the webhook handler is disabled by
    introducing a new error variable `ErrEventHandlerDisabled`.
    - Modified the `Init` method in `WebHookHandler` to return the new error
    when the webhook is disabled.
    - Updated the corresponding test to check for the
    `ErrEventHandlerDisabled` error instead of no error.
    
    
    ___
    
    
    
    ### **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>Add error
    handling for disabled webhook handler</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks.go
    <li>Added error handling for disabled webhook handler.<br> <li>
    Introduced <code>ErrEventHandlerDisabled</code> error variable.<br> <li>
    Modified <code>Init</code> method to return
    <code>ErrEventHandlerDisabled</code> when webhook is <br>disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+6/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    
    <summary><strong>event_handler_webhooks_test.go</strong><dd><code>Update
    test for disabled webhook handler error</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks_test.go
    - Updated test to check for `ErrEventHandlerDisabled` error.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-1a2f8d6ab4443031b0f8486809453f6389291a6f625745fe8c65ac5cdb0e9621">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </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
    
    (cherry picked from commit 3e5963c)
    @tykbot

    tykbot Bot commented Jun 11, 2024

    Copy link
    Copy Markdown

    @jeffy-mathew Succesfully merged PR

    buger added a commit that referenced this pull request Jun 11, 2024
    …s disabled (#6334)
    
    [TT-12323] fix panic when webhook handler is disabled (#6334)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
     fix panic when webhook handler is disabled
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-12323
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added error handling for when the webhook handler is disabled by
    introducing a new error variable `ErrEventHandlerDisabled`.
    - Modified the `Init` method in `WebHookHandler` to return the new error
    when the webhook is disabled.
    - Updated the corresponding test to check for the
    `ErrEventHandlerDisabled` error instead of no error.
    
    
    ___
    
    
    
    ### **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>Add error
    handling for disabled webhook handler</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks.go
    <li>Added error handling for disabled webhook handler.<br> <li>
    Introduced <code>ErrEventHandlerDisabled</code> error variable.<br> <li>
    Modified <code>Init</code> method to return
    <code>ErrEventHandlerDisabled</code> when webhook is <br>disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+6/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    
    <summary><strong>event_handler_webhooks_test.go</strong><dd><code>Update
    test for disabled webhook handler error</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks_test.go
    - Updated test to check for `ErrEventHandlerDisabled` error.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-1a2f8d6ab4443031b0f8486809453f6389291a6f625745fe8c65ac5cdb0e9621">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </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
    buger added a commit that referenced this pull request Jun 11, 2024
    …disabled (#6334)
    
    [TT-12323] fix panic when webhook handler is disabled (#6334)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
     fix panic when webhook handler is disabled
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-12323
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added error handling for when the webhook handler is disabled by
    introducing a new error variable `ErrEventHandlerDisabled`.
    - Modified the `Init` method in `WebHookHandler` to return the new error
    when the webhook is disabled.
    - Updated the corresponding test to check for the
    `ErrEventHandlerDisabled` error instead of no error.
    
    
    ___
    
    
    
    ### **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>Add error
    handling for disabled webhook handler</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks.go
    <li>Added error handling for disabled webhook handler.<br> <li>
    Introduced <code>ErrEventHandlerDisabled</code> error variable.<br> <li>
    Modified <code>Init</code> method to return
    <code>ErrEventHandlerDisabled</code> when webhook is <br>disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+6/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    
    <summary><strong>event_handler_webhooks_test.go</strong><dd><code>Update
    test for disabled webhook handler error</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks_test.go
    - Updated test to check for `ErrEventHandlerDisabled` error.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-1a2f8d6ab4443031b0f8486809453f6389291a6f625745fe8c65ac5cdb0e9621">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </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
    nerdydread pushed a commit that referenced this pull request Sep 6, 2024
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
     fix panic when webhook handler is disabled
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-12323
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added error handling for when the webhook handler is disabled by
    introducing a new error variable `ErrEventHandlerDisabled`.
    - Modified the `Init` method in `WebHookHandler` to return the new error
    when the webhook is disabled.
    - Updated the corresponding test to check for the
    `ErrEventHandlerDisabled` error instead of no error.
    
    
    ___
    
    
    
    ### **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>Add error
    handling for disabled webhook handler</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks.go
    <li>Added error handling for disabled webhook handler.<br> <li>
    Introduced <code>ErrEventHandlerDisabled</code> error variable.<br> <li>
    Modified <code>Init</code> method to return
    <code>ErrEventHandlerDisabled</code> when webhook is <br>disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+6/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    
    <summary><strong>event_handler_webhooks_test.go</strong><dd><code>Update
    test for disabled webhook handler error</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/event_handler_webhooks_test.go
    - Updated test to check for `ErrEventHandlerDisabled` error.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6334/files#diff-1a2f8d6ab4443031b0f8486809453f6389291a6f625745fe8c65ac5cdb0e9621">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </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
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants