### **User description**
<!-- Provide a general summary of your changes in the Title above -->
## Description
handle missed edge case where event handlers are empty.
## Related Issue
Parent task: https://tyktech.atlassian.net/browse/TT-11966
Sub task: https://tyktech.atlassian.net/browse/TT-12064
## 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: -->
- [x] 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 checks and initializations in `event.go` to handle scenarios
where event handlers are empty or undefined, preventing runtime errors.
- Enhanced test coverage in `event_test.go` to include tests for nil and
empty event handlers, ensuring robustness.
___
### **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.go</strong><dd><code>Handle edge cases and
initialization for empty event handlers</code></dd></summary>
<hr>
apidef/oas/event.go
<li>Added initialization of <code>EventHandlers</code> to handle cases
where event <br>handlers are empty.<br> <li> Ensured
<code>api.EventHandlers.Events</code> is initialized before use to
prevent <br>nil map assignments.<br>
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6267/files#diff-528a9f5b311ff21c0b3a9b273e61398209ca8b51550327e4d437bba81e49d577">+6/-5</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Tests
</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>event_test.go</strong><dd><code>Extend unit tests for
event handler edge cases</code>
</dd></summary>
<hr>
apidef/oas/event_test.go
<li>Added test cases for nil and empty event handlers.<br> <li> Modified
existing test cases to include scenarios with pre-existing <br>event
handlers.<br>
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6267/files#diff-a1f19f96579a470e73c131a0e37895da0c21d378f6aa48067608274564e62da7">+34/-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
User description
Description
handle missed edge case where event handlers are empty.
Related Issue
Parent task: https://tyktech.atlassian.net/browse/TT-11966
Sub task: https://tyktech.atlassian.net/browse/TT-12064
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
event.goto handle scenarios where event handlers are empty or undefined, preventing runtime errors.event_test.goto include tests for nil and empty event handlers, ensuring robustness.Changes walkthrough 📝
event.go
Handle edge cases and initialization for empty event handlersapidef/oas/event.go
EventHandlersto handle cases where eventhandlers are empty.
api.EventHandlers.Eventsis initialized before use to preventnil map assignments.
event_test.go
Extend unit tests for event handler edge casesapidef/oas/event_test.go
event handlers.