Skip to content

[TT-15507] Reverting /hello endpoint to always return 200 status code #7280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from

Conversation

mativm02
Copy link
Contributor

@mativm02 mativm02 commented Aug 7, 2025

User description

Description

Related Issue

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


Description

  • Reverts /hello (liveness) endpoint to always return HTTP 200

  • Removes logic for dynamic HTTP status based on health checks

  • Ensures JSON encoding errors are logged in readiness handler

  • Simplifies health status calculation for liveness endpoint


Diagram Walkthrough

flowchart LR
  oldLogic["Dynamic HTTP status for /hello"] -- "removed" --> static200["Always return HTTP 200"]
  healthChecks["Health check evaluation"] -- "simplified" --> statusCalc["Simplified status calculation"]
  readinessHandler["Readiness handler"] -- "add error logging" --> errorLog["Logs JSON encoding errors"]
Loading

File Walkthrough

Relevant files
Bug fix
health_check.go
Revert liveness endpoint to static 200 and improve error logging

gateway/health_check.go

  • /hello endpoint now always returns HTTP 200 status
  • Removed dynamic status code logic based on health checks
  • Simplified health status calculation for liveness checks
  • Added error logging for JSON encoding in readiness handler
+24/-4   

buger and others added 21 commits June 23, 2025 17:38
…s to OAS (#7101) (#7134)

### **User description**
[TT-7932] Errors migrating some versioned APIs to OAS (#7101)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-7932"
title="TT-7932" target="_blank">TT-7932</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Errors migrating some versioned APIs to OAS</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

## Description

When migrating a Swagger 2.0 API to a Tyk OAS API using the API
migration endpoint or UI, the migration fails with a validation error
related to the versioning field. The error occurs because the migration
process incorrectly sets the versions field to null instead of an empty
array [] when the source API doesn't have versioning information.

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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**
- Fix migration bug for APIs without versioning info

- Ensure `Versions` is set to empty array, not null

- Update test to initialize `Versions` as empty array


___



### **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>root.go</strong><dd><code>Preserve empty array for
Versions in migration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/root.go

<li>Removed logic that set <code>Versions</code> to nil when empty<br>
<li> Now always preserves empty array for <code>Versions</code>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7101/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>root_test.go</strong><dd><code>Test empty Versions
array initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

apidef/oas/root_test.go

<li>Updated test to initialize <code>Versions</code> as empty array<br>
<li> Ensures correct handling of empty versioning in tests


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7101/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-7932]:
https://tyktech.atlassian.net/browse/TT-7932?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Tests


___

### **Description**
- Fix migration bug for APIs missing versioning info

- Ensure `Versions` is set to empty array, not null

- Remove logic that sets `Versions` to nil in migration

- Update test to initialize `Versions` as empty array


___



### **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>root.go</strong><dd><code>Preserve empty array for
Versions in migration logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

apidef/oas/root.go

<li>Removed logic that set <code>Versions</code> to nil when empty<br>
<li> Now always preserves empty array for <code>Versions</code>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7134/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>root_test.go</strong><dd><code>Test empty Versions
array initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

apidef/oas/root_test.go

<li>Updated test to initialize <code>Versions</code> as empty array<br>
<li> Ensures correct handling of empty versioning in tests


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7134/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Maciej Miś <[email protected]>
… in Tyk OAS API Debugger (#7113) (#7140)

### **User description**
[TT-14914] No response middleware information in Tyk OAS API Debugger
(#7113)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14914"
title="TT-14914" target="_blank">TT-14914</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td> No response middleware information in Tyk OAS API Debugger</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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)
- [x] 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**
Enhancement, Bug fix


___

### **Description**
- Add structured logging to all response middleware handlers

- Introduce middleware decorators for response logging

- Refactor response middleware chain creation for consistent logging

- Update response middleware interfaces to support logger injection


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>10
files</summary><table>
<tr>
<td><strong>middleware_decorators.go</strong><dd><code>Add response
middleware decorator for logging</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-fa58c743ea567e4559ce0d281d5ba46fa5c74b20b4b99199fa66931077be487a">+64/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Refactor response middleware
chain to use decorators and logging</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+21/-11</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>middleware.go</strong><dd><code>Add logger support to
response middleware base and interface</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+18/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>api_loader.go</strong><dd><code>Pass logger to response
middleware chain creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_header_injector.go</strong><dd><code>Use
structured logger for header injector middleware</code>&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-db30365a54a06d3fbf9f4aad3fe133de85dbb75fae2177d84ede3214407f31ca">+8/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_transform.go</strong><dd><code>Use structured
logger for response transform middleware</code>&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-f8499feb1343c99c7356d52ffd87f87d09af4c829daf3bb05b30bbceba47b9c1">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_jq_transform_dummy.go</strong><dd><code>Use
structured logger for JQ transform dummy middleware</code>&nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-f58ff32e282dfacc62320463b8c526091b25358a00e1cc6ae11325b03aa05cfe">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_cache.go</strong><dd><code>Use structured logger for
response cache middleware</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-b073df547bd9290da2477f24069cb6f0661f3fb1655b276aa206d938c8ca5f02">+5/-11</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_go_plugin.go</strong><dd><code>Use structured
logger for Go plugin response middleware</code>&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-6f8975149bf9fc9034010738cb14f23f240ffc5521cdbe43a82b12d2072f68f4">+17/-26</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>coprocess.go</strong><dd><code>Use structured logger for
coprocess response hook</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7113/files#diff-9cbfe628982b2afb94d1e9a5200fc9a4fdc00cb58fe65d1090a3725e4e4c5953">+6/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-14914]:
https://tyktech.atlassian.net/browse/TT-14914?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Enhancement, Bug fix


___

### **Description**
- Add structured logging to all response middleware handlers

- Introduce middleware decorators for response logging

- Refactor response middleware chain for consistent logging

- Update response middleware interfaces to support logger injection


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>13
files</summary><table>
<tr>
<td><strong>middleware_decorators.go</strong><dd><code>Add response
middleware decorator for structured logging</code>&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-fa58c743ea567e4559ce0d281d5ba46fa5c74b20b4b99199fa66931077be487a">+64/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Refactor response middleware
chain to use decorators and logging</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+25/-15</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>middleware.go</strong><dd><code>Add logger support to
response middleware base and interface</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+18/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>api_loader.go</strong><dd><code>Pass logger to response
middleware chain creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_header_injector.go</strong><dd><code>Use
structured logger for header injector middleware</code>&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-db30365a54a06d3fbf9f4aad3fe133de85dbb75fae2177d84ede3214407f31ca">+8/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_transform.go</strong><dd><code>Use structured
logger for response transform middleware</code>&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-f8499feb1343c99c7356d52ffd87f87d09af4c829daf3bb05b30bbceba47b9c1">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_jq_transform_dummy.go</strong><dd><code>Use
structured logger for JQ transform dummy middleware</code>&nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-f58ff32e282dfacc62320463b8c526091b25358a00e1cc6ae11325b03aa05cfe">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>res_cache.go</strong><dd><code>Use structured logger for
response cache middleware</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-b073df547bd9290da2477f24069cb6f0661f3fb1655b276aa206d938c8ca5f02">+5/-11</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>res_handler_go_plugin.go</strong><dd><code>Use structured
logger for Go plugin response middleware</code>&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-6f8975149bf9fc9034010738cb14f23f240ffc5521cdbe43a82b12d2072f68f4">+17/-26</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>coprocess.go</strong><dd><code>Use structured logger for
coprocess response hook</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-9cbfe628982b2afb94d1e9a5200fc9a4fdc00cb58fe65d1090a3725e4e4c5953">+6/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>builder.go</strong><dd><code>Add helpers for response
header/body transform middleware</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-be3e44eb5029c9f950164be1e80b16d9252f998cb83441dcb81d21ac664b4c69">+29/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>middleware.go</strong><dd><code>Add helper to append add
operation to TransformHeaders</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+5/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tracing.go</strong><dd><code>Add response/request type to
trace log entries</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+15/-7</a>&nbsp;
&nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>tracing_test.go</strong><dd><code>Expand and refactor trace
handler tests for middleware and logging</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-17a8010aa6755f9c464858ca32ade86af22931c1671b644b97b0a6f984ead54b">+311/-210</a></td>

</tr>

</table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>2
files</summary><table>
<tr>
<td><strong>go.mod</strong><dd><code>Add go-httpbin/v2 dependency for
testing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>go.sum</strong><dd><code>Add checksum for go-httpbin/v2
dependency</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7140/files#diff-3295df7234525439d778f1b282d146a4f1ff6b415248aaac074e8042d9f42d63">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Yaroslav Kotsur <[email protected]>
…) (#7144)

### **User description**
[TT-14839] Update version on swagger yml (#7141)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14839"
title="TT-14839" target="_blank">TT-14839</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Update docs for Dashboard changes</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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**
Documentation


___

### **Description**
- Updated API version in `swagger.yml` from 5.8.0 to 5.9.0

- Ensured documentation reflects the latest release


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>swagger.yml</strong><dd><code>Update API version to
5.9.0 in Swagger YAML</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

swagger.yml

<li>Changed the <code>version</code> field from 5.8.0 to 5.9.0 in the
API info section.<br> <li> Ensured API documentation version matches the
latest release.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7141/files#diff-8f3c4cb253eee09ae2401daa7279a8bbfbfd4168bb579c3ac0ee5c672d63bb2c">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-14839]:
https://tyktech.atlassian.net/browse/TT-14839?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Documentation


___

### **Description**
- Updated API version in `swagger.yml` from 5.8.0 to 5.9.0

- Ensured API documentation reflects the latest release


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>swagger.yml</strong><dd><code>Bump API version to 5.9.0
in Swagger YAML</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

swagger.yml

<li>Changed the <code>version</code> field from 5.8.0 to 5.9.0 in the
API info section.<br> <li> Ensured API documentation version matches the
latest release.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7144/files#diff-8f3c4cb253eee09ae2401daa7279a8bbfbfd4168bb579c3ac0ee5c672d63bb2c">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Laurentiu <[email protected]>
…) (#7149)

### **User description**
[TT-8963] Unable to loop mocked endpoint (#7105)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-8963"
title="TT-8963" target="_blank">TT-8963</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Unable to loop mocked endpoint</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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)
- [x] 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, Enhancement, Tests


___

### **Description**
- Refactored mock response handling into dedicated middleware

- Improved detection and processing of active OAS mock responses

- Added comprehensive unit tests for mock response middleware

- Updated API spec and routing logic for middleware integration


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>10
files</summary><table>
<tr>
<td><strong>event.go</strong><dd><code>Use new header mapping utility in
webhook config</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-528a9f5b311ff21c0b3a9b273e61398209ca8b51550327e4d437bba81e49d577">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>header.go</strong><dd><code>Refactor header mapping and add
header addition method</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-0df51be6c650a8f510e1bc8b7b532f010bb7dbeb6841e6e84b37d368c12fd41e">+6/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>api_definition.go</strong><dd><code>Add path rewriting and
refactor mock detection logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-0cf80174bbafb36f6d4f4308ebbd971b2833b76a936bad568220aa1a4ba0ee8b">+16/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>api_loader.go</strong><dd><code>Integrate mock response
middleware in middleware chain</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+4/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>model_apispec.go</strong><dd><code>Refactor OAS router usage
and operation finding logic</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-80c49b9bdb411a3d5a4706ec3ff138ef44154d0306040c19eba1cb5559f199d6">+15/-9</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mw_mock_response.go</strong><dd><code>Extract and implement
mock response as standalone middleware</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+76/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mw_oas_validate_request.go</strong><dd><code>Use new
operation finding logic in request validation</code>&nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-f5de96d1354ffab65e076f23a58337a7799a212f6e70dea59b56576042ecd69a">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_version_check.go</strong><dd><code>Remove legacy
SetupOperation call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-ea28ed4980be684295449af109cad7cef58b8823d9f270ab3f1537441645579a">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>reverse_proxy.go</strong><dd><code>Remove legacy mock
response handling from reverse proxy</code>&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+0/-6</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tracing.go</strong><dd><code>Update tracing handler to new
subroute generation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+3/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>


</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4
files</summary><table>
<tr>
<td><strong>header_test.go</strong><dd><code>Update tests for new header
mapping function</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-3f889a92dbfb32e1fa85b9c50793063836eacc5aced049134917b5a0fda2c463">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>api_definition_test.go</strong><dd><code>Update tests for
new mock detection method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-2394daab6fdc5f8dc234699c80c0548947ee3d68d2e33858258d73a8b5eb6f44">+8/-8</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_mock_response_test.go</strong><dd><code>Add comprehensive
tests for mock response middleware</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-ec0f656660a941868ea6c8fdd5116fe3f385f3de107aed70b7ecf0cc215c503e">[link]</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>tracing_test.go</strong><dd><code>Use new header addition
method in mock setup for tests</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-17a8010aa6755f9c464858ca32ade86af22931c1671b644b97b0a6f984ead54b">+3/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>


</table></details></td></tr><tr><td><strong>Miscellaneous</strong></td><td><details><summary>2
files</summary><table>
<tr>
<td><strong>ctx.go</strong><dd><code>Remove unused OASOperation context
key</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-600f5f552779994b15324fda108549eec7e7be30b1d8a1a16ee8344243e0cbc7">+0/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>api.go</strong><dd><code>Remove unused OAS operation context
functions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7105/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+10/-10</a>&nbsp;
</td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>


___
### Report

In general, the work included:

1. Creation of a new mockResponseMiddleware: A middleware component was
implemented that intercepts API requests and returns mock responses when
configured, eliminating the need to call upstream services.
2. Support for two mock response types was added:
- Custom mock responses with manually configured status codes, bodies,
and headers
- Mock responses derived from OpenAPI examples defined in API
specifications
4. Resolution of an issue with looping through mocked endpoints: The
branch name suggests there was a problem with iterating through mocked
endpoints, which was resolved. This likely involved ensuring proper
handling of multiple mock configurations or preventing infinite loops in
certain scenarios.
5. Implementation of proper redirect handling: Functionality was added
to correctly handle HTTP redirects when using mock responses, ensuring
that redirect responses work as expected.
6. Addition of tests: Tests were created to verify the functionality of
the mock response middleware, ensuring it correctly handles various
scenarios.

This enhancement improves the API gateway's simulation capabilities,
making it more useful for testing and development environments where
actual upstream services might not be available or where controlled
responses are needed for testing specific scenarios.

[TT-8963]:
https://tyktech.atlassian.net/browse/TT-8963?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement, Tests


___

### **Description**
- Refactored mock response logic into standalone middleware

- Improved detection and handling of active OAS mock responses

- Added comprehensive unit tests for mock response middleware and
internal redirects

- Updated API spec, routing, and tracing logic for middleware
integration


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>10
files</summary><table>
<tr>
<td><strong>builder.go</strong><dd><code>Refactor OAS builder for
improved test setup and mock defaults</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-be3e44eb5029c9f950164be1e80b16d9252f998cb83441dcb81d21ac664b4c69">+50/-8</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>header.go</strong><dd><code>Refactor header mapping and add
header addition method</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-0df51be6c650a8f510e1bc8b7b532f010bb7dbeb6841e6e84b37d368c12fd41e">+12/-3</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>api_definition.go</strong><dd><code>Add path rewriting and
refactor mock detection logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-0cf80174bbafb36f6d4f4308ebbd971b2833b76a936bad568220aa1a4ba0ee8b">+21/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>api_loader.go</strong><dd><code>Integrate mock response
middleware in middleware chain and subroute
</code><br><code>generation</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+17/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>model_apispec.go</strong><dd><code>Refactor OAS router usage
and operation finding logic</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-80c49b9bdb411a3d5a4706ec3ff138ef44154d0306040c19eba1cb5559f199d6">+18/-10</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>mw_mock_response.go</strong><dd><code>Extract and implement
mock response as standalone middleware</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+80/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mw_oas_validate_request.go</strong><dd><code>Use new
operation finding logic in request validation</code>&nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-f5de96d1354ffab65e076f23a58337a7799a212f6e70dea59b56576042ecd69a">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_version_check.go</strong><dd><code>Remove legacy
SetupOperation call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-ea28ed4980be684295449af109cad7cef58b8823d9f270ab3f1537441645579a">+0/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>reverse_proxy.go</strong><dd><code>Remove legacy mock
response handling from reverse proxy</code>&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+0/-6</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tracing.go</strong><dd><code>Update tracing handler to new
subroute generation and log structure</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+2/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Miscellaneous</strong></td><td><details><summary>2
files</summary><table>
<tr>
<td><strong>ctx.go</strong><dd><code>Remove unused OASOperation context
key, add internal redirect target</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-600f5f552779994b15324fda108549eec7e7be30b1d8a1a16ee8344243e0cbc7">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>api.go</strong><dd><code>Remove unused OAS operation context
functions, add internal redirect
</code><br><code>helpers</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+19/-19</a>&nbsp;
</td>

</tr>

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4
files</summary><table>
<tr>
<td><strong>api_definition_test.go</strong><dd><code>Update tests for
new mock detection method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-2394daab6fdc5f8dc234699c80c0548947ee3d68d2e33858258d73a8b5eb6f44">+8/-8</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_mock_response_test.go</strong><dd><code>Add comprehensive
tests for mock response middleware and redirects</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-ec0f656660a941868ea6c8fdd5116fe3f385f3de107aed70b7ecf0cc215c503e">+81/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>tracing_test.go</strong><dd><code>Use new header addition
and OAS builder methods in tests</code>&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-17a8010aa6755f9c464858ca32ade86af22931c1671b644b97b0a6f984ead54b">+31/-19</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>tyk_tykprotocol_200.yml</strong><dd><code>Fix typo in
tracing scenario name for tykprotocol</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-208ea307f413f94d5c607391304371c84f78de69da0568826585ab5293fb680b">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>mw_virtual_endpoint.go</strong><dd><code>Update comment for
VirtualEndpoint middleware</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-daf72ac3b29609a9f2a77cccf648f91ba62b2ad977a7c5a44602c72b2a28b2e5">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr><tr><td><strong>Configuration
changes</strong></td><td><details><summary>1 files</summary><table>
<tr>
<td><strong>.dockerignore</strong><dd><code>Add go.work and go.work.sum
to dockerignore</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7149/files#diff-2f754321d62f08ba8392b9b168b83e24ea2852bb5d815d63e767f6c3d23c6ac5">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Yaroslav Kotsur <[email protected]>
…#7157) (#7160)

### **User description**
[TT-14838] Addressed gw documentation reviews (#7157)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14838"
title="TT-14838" target="_blank">TT-14838</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td> Update docs for Gateway changes</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Code Review</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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**
Documentation


___

### **Description**
- Updated deprecation notice for `ExternalOAuth` to clarify version and
product.

- Improved description for `ContextVariables.Enabled` to specify
applicable middleware.

- Enhanced documentation for `JwksURIs` to clarify its purpose and
usage.


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Clarify ExternalOAuth deprecation notice"] -- "Update comments" --> B["apidef/api_definitions.go"]
  C["Improve ContextVariables.Enabled description"] -- "Update struct field comment" --> D["apidef/oas/middleware.go"]
  E["Enhance JwksURIs documentation"] -- "Update struct field comment" --> F["apidef/oas/security.go"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_definitions.go</strong><dd><code>Clarify
ExternalOAuthType deprecation and guidance</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/api_definitions.go

<li>Updated deprecation comment for <code>ExternalOAuthType</code> to
specify <br>deprecation in Tyk 5.7.0.<br> <li> Clarified recommendation
to use JWT with reference link.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7157/files#diff-9961ccc89a48d32db5b47ba3006315ef52f6e5007fb4b09f8c5d6d299c669d67">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Specify middleware for
ContextVariables.Enabled</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/middleware.go

<li>Improved comment for <code>ContextVariables.Enabled</code> to
specify which <br>middleware are affected.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7157/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>security.go</strong><dd><code>Refine JwksURIs and
ExternalOAuth documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/security.go

<li>Enhanced <code>JwksURIs</code> comment to clarify its role in JWT
validation.<br> <li> Updated deprecation comment for
<code>ExternalOAuth</code> to specify Tyk 5.7.0.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7157/files#diff-15e7d47137452ca4f3f6139aa8c007cdb426152c41846f712f8bf5dfb607afcc">+2/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-14838]:
https://tyktech.atlassian.net/browse/TT-14838?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Documentation


___

### **Description**
- Clarified deprecation notice for `ExternalOAuth` in Tyk 5.7.0.

- Improved `ContextVariables.Enabled` comment to specify affected
middleware.

- Enhanced `JwksURIs` documentation to clarify JWT validation usage.


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Clarify ExternalOAuth deprecation notice"] -- "Update comments" --> B["apidef/api_definitions.go"]
  C["Improve ContextVariables.Enabled description"] -- "Update struct field comment" --> D["apidef/oas/middleware.go"]
  E["Enhance JwksURIs documentation"] -- "Update struct field comment" --> F["apidef/oas/security.go"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_definitions.go</strong><dd><code>Clarify
ExternalOAuthType deprecation and guidance</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/api_definitions.go

<li>Updated deprecation comment for <code>ExternalOAuthType</code> to
specify Tyk <br>5.7.0.<br> <li> Clarified recommendation to use JWT with
documentation link.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7160/files#diff-9961ccc89a48d32db5b47ba3006315ef52f6e5007fb4b09f8c5d6d299c669d67">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Specify middleware for
ContextVariables.Enabled</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/middleware.go

<li>Improved comment for <code>ContextVariables.Enabled</code> to
specify which <br>middleware are affected.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7160/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>security.go</strong><dd><code>Refine JwksURIs and
ExternalOAuth documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/security.go

<li>Enhanced <code>JwksURIs</code> comment to clarify its role in JWT
validation.<br> <li> Updated deprecation comment for
<code>ExternalOAuth</code> to specify Tyk 5.7.0.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7160/files#diff-15e7d47137452ca4f3f6139aa8c007cdb426152c41846f712f8bf5dfb607afcc">+2/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Laurentiu <[email protected]>
… in Tyk OAS API Debugger (#7158) (#7165)

### **User description**
[TT-14914] No response middleware information in Tyk OAS API Debugger
(#7158)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14914"
title="TT-14914" target="_blank">TT-14914</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td> No response middleware information in Tyk OAS API Debugger</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Code Review</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description
Provided changes:
1. Mocked response should have pass through response mw pipeline.
2. Builder from oas package moved to internal package named oas builder,
due to Laurentu's request.

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## Motivation and Context

<!-- Why is this change required? What problem does it solve? -->

## How This Has Been Tested
1. It was tested manually.

## 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)
- [x] 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**
Enhancement, Bug fix


___

### **Description**
- Refactored OAS builder to internal package `oasbuilder`

- Updated all usages to reference new `oasbuilder` package

- Fixed response middleware chain assignment and handling

- Standardized middleware status codes and improved code clarity


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Move OAS builder to internal/oasbuilder"] -- "Refactor imports/usages" --> B["Update references in tracing_test.go"]
  B -- "Update endpoint builder usage" --> C["Standardize middleware status codes"]
  C -- "Improve response middleware chain" --> D["Fix response chain assignment in processSpec"]
  D -- "Enhance mock response middleware" --> E["Update related gateway files"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>11
files</summary><table>
<tr>
<td><strong>builder.go</strong><dd><code>Move and refactor OAS builder
to internal package</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-5d782e3804be22e326c374b6d2e39c588e06dc064b9788aa5fe6bc21584e6ebb">+31/-49</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>middleware.go</strong><dd><code>Standardize middleware
status codes and handler logic</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+4/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_mock_response.go</strong><dd><code>Refactor mock response
middleware and response chain handling</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+13/-14</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>mw_redis_cache.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-6266e0dbd16cef89e6de86a2c893114ba07799c804e2138172f9f94b08cdded8">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_js_plugin.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-78cd278aba997558b7daa7897051a794ef860076d45c93be792791db39381ca0">+3/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_go_plugin.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-0f31abef73bf795e1a8d331202330c73011a74d10fd66e49b9359716a6d18fd9">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_virtual_endpoint.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-daf72ac3b29609a9f2a77cccf648f91ba62b2ad977a7c5a44602c72b2a28b2e5">+2/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_version_check.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-ea28ed4980be684295449af109cad7cef58b8823d9f270ab3f1537441645579a">+3/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>coprocess.go</strong><dd><code>Use standardized middleware
status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-9cbfe628982b2afb94d1e9a5200fc9a4fdc00cb58fe65d1090a3725e4e4c5953">+7/-8</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tracing.go</strong><dd><code>Add String() to traceLogType
and minor cleanup</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+5/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Refactor response middleware
chain creation to return chain</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+2/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>


</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>tracing_test.go</strong><dd><code>Update OAS builder usage
to internal/oasbuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-17a8010aa6755f9c464858ca32ade86af22931c1671b644b97b0a6f984ead54b">+14/-13</a>&nbsp;
</td>

</tr>
</table></details></td></tr><tr><td><strong>Bug
fix</strong></td><td><details><summary>1 files</summary><table>
<tr>
<td><strong>api_loader.go</strong><dd><code>Fix response middleware
chain assignment and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7158/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+3/-7</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-14914]:
https://tyktech.atlassian.net/browse/TT-14914?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Enhancement, Bug fix, Tests


___

### **Description**
- Refactored OAS builder to internal `oasbuilder` package

- Fixed response middleware chain assignment and handling

- Standardized middleware status codes across middlewares

- Updated tests and usages to reference new builder location


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Move OAS builder to internal/oasbuilder"] -- "Update imports/usages" --> B["Update tracing_test.go and related files"]
  B -- "Refactor response middleware chain" --> C["Fix assignment in processSpec"]
  C -- "Standardize status codes" --> D["Update all middleware files"]
  D -- "Enhance mock response handling" --> E["Improve response chain processing"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>11
files</summary><table>
<tr>
<td><strong>builder.go</strong><dd><code>Move and refactor OAS builder
to internal package</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-5d782e3804be22e326c374b6d2e39c588e06dc064b9788aa5fe6bc21584e6ebb">+31/-49</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Refactor response middleware
chain creation to return chain</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+2/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_mock_response.go</strong><dd><code>Refactor mock response
middleware and response chain handling</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+13/-14</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>middleware.go</strong><dd><code>Standardize middleware
status codes and handler logic</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+4/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_redis_cache.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-6266e0dbd16cef89e6de86a2c893114ba07799c804e2138172f9f94b08cdded8">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_js_plugin.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-78cd278aba997558b7daa7897051a794ef860076d45c93be792791db39381ca0">+3/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_go_plugin.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-0f31abef73bf795e1a8d331202330c73011a74d10fd66e49b9359716a6d18fd9">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_virtual_endpoint.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-daf72ac3b29609a9f2a77cccf648f91ba62b2ad977a7c5a44602c72b2a28b2e5">+2/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mw_version_check.go</strong><dd><code>Use standardized
middleware status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-ea28ed4980be684295449af109cad7cef58b8823d9f270ab3f1537441645579a">+3/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>coprocess.go</strong><dd><code>Use standardized middleware
status code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-9cbfe628982b2afb94d1e9a5200fc9a4fdc00cb58fe65d1090a3725e4e4c5953">+7/-8</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tracing.go</strong><dd><code>Add String() to traceLogType
and minor cleanup</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-0069987d730b02812808925a17e1434ca7558a4dfc8661beb27ccd11afb8c77d">+5/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>tracing_test.go</strong><dd><code>Update OAS builder usage
to internal/oasbuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-17a8010aa6755f9c464858ca32ade86af22931c1671b644b97b0a6f984ead54b">+14/-13</a>&nbsp;
</td>

</tr>
</table></details></td></tr><tr><td><strong>Bug
fix</strong></td><td><details><summary>1 files</summary><table>
<tr>
<td><strong>api_loader.go</strong><dd><code>Fix response middleware
chain assignment and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7165/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+3/-7</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Yaroslav Kotsur <[email protected]>
…d policy sync cherrypick (#7167) (#7174)

### **User description**
[TT-15059][TT-11285] MDCB DNS critical fix and policy sync cherrypick
(#7167)

### **User description**
<!-- Provide a general summary of your changes in the Title above -->

This PR contains the changes introduced in
#7127 and
#7136 but merged together to
allow for an easier release process.

This PR introduces a DNS refresh mechanism together with a bugfix around
the synchronization of policies when the connection to MDCB would time
out.

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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, Enhancement, Tests


___

### **Description**
- Add DNS-based self-healing for RPC connection failures
  - Detect DNS changes and reconnect RPC client on failure
  - Only check DNS once per disconnection event

- Trigger emergency mode and load from backup on repeated RPC timeouts
  - Ensures gateway uses Redis backup if MDCB is unreachable

- Improve error handling for retriable RPC/network errors
  - Extend retriable error detection to include timeouts

- Add comprehensive unit tests for DNS logic and emergency mode


___

### **Changes diagram**

```mermaid
flowchart LR
  A["RPC connection fails"] -- "Check DNS once" --> B["DNS changed?"]
  B -- "Yes" --> C["Reconnect RPC client"]
  B -- "No" --> D["Log warning, no reconnect"]
  A -- "All retries fail" --> E["Trigger emergency mode"]
  E -- "Load from backup" --> F["Gateway uses Redis backup"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><details><summary>1 files</summary><table>
<tr>
<td><strong>policy.go</strong><dd><code>Add error handling for empty RPC
policy responses</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-ec674104322b26b82def55e9be32117753ab66e7840490481eb6eb4c15bc35e7">+3/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>


</table></details></td></tr><tr><td><strong>Enhancement</strong></td><td><details><summary>5
files</summary><table>
<tr>
<td><strong>rpc_storage_handler.go</strong><dd><code>Extend retriable
error detection for timeouts</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-8875f75b602664c44b62b67a4da41d748124ad270573a44db4ec977ee5d68021">+9/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Trigger emergency mode and
backup loading on repeated RPC failures</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+23/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>dns_resolver.go</strong><dd><code>Add DNS resolution and
self-healing reconnection logic</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-3d4fcf2e5b1a8e522dcc0dc656f64dfa85e53f41e8c46c5466d422b8d56d8a82">+130/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>rpc_client.go</strong><dd><code>Integrate DNS check, error
handling, and emergency mode controls</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-3b88914c99bb9418e44e6389ce73579843562e8900730b380d7fff2e95c51033">+67/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>utils.go</strong><dd><code>Add utility functions for DNS and
network error detection</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-659e102b74cf8cae4db311100e475bee88ba1be6dd7b450c1e060dfee2fb3761">+36/-0</a>&nbsp;
&nbsp; </td>

</tr>


</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4
files</summary><table>
<tr>
<td><strong>rpc_storage_handler_test.go</strong><dd><code>Add unit tests
for retriable error logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-69de989a02b3bc32ae376c514ee84633c609200db22385c0e16c361d6ea74cd6">+35/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>server_test.go</strong><dd><code>Add tests for emergency
mode and backup fallback logic</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-d9f006370c9748c09affd99d0a4edeb8f3419057703a67fd70838a764a485696">+44/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>dns_resolver_test.go</strong><dd><code>Add comprehensive
unit tests for DNS resolution and reconnection</code></dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-1f9e4fa330ed10e933704c2e1eb7c7244fcb2e7290fab58f248fedd18f1d6f0f">+501/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>utils_test.go</strong><dd><code>Add unit tests for utility
functions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7167/files#diff-509db1da354a66f1ed878475d2ca736b989cc45f3260caf3e7933704f74f766a">+143/-0</a>&nbsp;
</td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

---------

Co-authored-by: sredny buitrago <[email protected]>

[TT-15059]:
https://tyktech.atlassian.net/browse/TT-15059?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement, Tests


___

### **Description**
- Add DNS-based self-healing for MDCB RPC failures
  - Detect DNS changes and reconnect RPC client on error
  - Only check DNS once per disconnection event

- Trigger emergency mode and load from backup on repeated RPC timeouts
  - Ensures gateway uses Redis backup if MDCB is unreachable

- Improve error handling for retriable RPC/network errors
  - Extend retriable error detection to include timeouts

- Add comprehensive unit tests for DNS logic, emergency mode, and
utilities


___

### **Changes diagram**

```mermaid
flowchart LR
  A["RPC connection fails"] -- "Check DNS once" --> B["DNS changed?"]
  B -- "Yes" --> C["Reconnect RPC client"]
  B -- "No" --> D["Log warning, no reconnect"]
  A -- "All retries fail" --> E["Trigger emergency mode"]
  E -- "Load from backup" --> F["Gateway uses Redis backup"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><details><summary>1 files</summary><table>
<tr>
<td><strong>policy.go</strong><dd><code>Add error handling for empty RPC
policy responses</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-ec674104322b26b82def55e9be32117753ab66e7840490481eb6eb4c15bc35e7">+3/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Enhancement</strong></td><td><details><summary>5
files</summary><table>
<tr>
<td><strong>rpc_storage_handler.go</strong><dd><code>Extend retriable
error detection for timeouts</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-8875f75b602664c44b62b67a4da41d748124ad270573a44db4ec977ee5d68021">+9/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Trigger emergency mode and
backup loading on repeated RPC failures</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+23/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>dns_resolver.go</strong><dd><code>Add DNS resolution and
self-healing reconnection logic</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-3d4fcf2e5b1a8e522dcc0dc656f64dfa85e53f41e8c46c5466d422b8d56d8a82">+130/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>rpc_client.go</strong><dd><code>Integrate DNS check, error
handling, and emergency mode controls</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-3b88914c99bb9418e44e6389ce73579843562e8900730b380d7fff2e95c51033">+67/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>utils.go</strong><dd><code>Add utility functions for DNS and
network error detection</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-659e102b74cf8cae4db311100e475bee88ba1be6dd7b450c1e060dfee2fb3761">+36/-0</a>&nbsp;
&nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4
files</summary><table>
<tr>
<td><strong>rpc_storage_handler_test.go</strong><dd><code>Add unit tests
for retriable error logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-69de989a02b3bc32ae376c514ee84633c609200db22385c0e16c361d6ea74cd6">+35/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>server_test.go</strong><dd><code>Add tests for emergency
mode and backup fallback logic</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-d9f006370c9748c09affd99d0a4edeb8f3419057703a67fd70838a764a485696">+44/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>dns_resolver_test.go</strong><dd><code>Add comprehensive
unit tests for DNS resolution and reconnection</code></dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-1f9e4fa330ed10e933704c2e1eb7c7244fcb2e7290fab58f248fedd18f1d6f0f">+501/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>utils_test.go</strong><dd><code>Add unit tests for utility
functions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7174/files#diff-509db1da354a66f1ed878475d2ca736b989cc45f3260caf3e7933704f74f766a">+143/-0</a>&nbsp;
</td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: andrei-tyk <[email protected]>
…rt for legacy TLS cipher suites (#7173) (#7183)

### **User description**
[TT-14990] Update GetCiphers to restore support for legacy TLS cipher
suites (#7173)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14990"
title="TT-14990" target="_blank">TT-14990</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>[Regression] Missing TLS Ciphers in Tyk v5.8</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC"
title="customer_bug">customer_bug</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC"
title="jira_escalated">jira_escalated</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->
This PR addresses an issue introduced in Tyk Gateway v5.8.1 where
several previously supported TLS 1.2 cipher suites were no longer
recognized when specified in the configuration. These include legacy
ciphers like TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_3DES_EDE_CBC_SHA, and others that are still required by
certain legacy clients and devices. It also adds backward compatibility
for legacy cipher names like TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, which
Go internally maps to ..._SHA256.

In Go, these cipher suites are no longer returned by tls.CipherSuites()
alone, as they are considered insecure. However, they can still be
explicitly enabled by using tls.InsecureCipherSuites().

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->
https://tyktech.atlassian.net/browse/TT-14990

## 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**
- Restores legacy/insecure TLS cipher suites in `GetCiphers`

- Adds backward compatibility for legacy cipher suite names

- Expands and improves unit tests for cipher suite handling

- Ensures correct mapping and resolution of legacy cipher names


___

### **Changes diagram**

```mermaid
flowchart LR
  A["GetCiphers()"] -- "now includes" --> B["Secure ciphers"]
  A -- "now includes" --> C["Insecure/legacy ciphers"]
  D["cipherNamesEqual()"] -- "maps legacy names" --> E["Canonical cipher names"]
  F["Unit tests"] -- "expanded for" --> G["Legacy cipher handling"]
```


___



### **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>ciphers.go</strong><dd><code>Restore legacy cipher
suites and add legacy name mapping</code>&nbsp; </dd></summary>
<hr>

internal/crypto/ciphers.go

<li>Appends insecure cipher suites to <code>GetCiphers</code> output<br>
<li> Adds <code>cipherNamesEqual</code> for legacy-canonical cipher name
mapping<br> <li> Updates <code>ResolveCipher</code> to use new name
comparison logic<br> <li> Improves backward compatibility for legacy
cipher suite names


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7183/files#diff-86698d97685ca2876f216471bdf44651d965be0b5c80ee67fa3dbb31929431e5">+25/-2</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>ciphers_test.go</strong><dd><code>Add and expand tests
for legacy cipher suite handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

internal/crypto/ciphers_test.go

<li>Adds tests for legacy cipher suites presence in
<code>GetCiphers</code><br> <li> Expands <code>TestResolveCipher</code>
for legacy name resolution<br> <li> Introduces
<code>TestCipherNamesEqual</code> for name mapping logic<br> <li>
Improves test coverage for cipher suite compatibility


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7183/files#diff-6682fccccf9d48c22219d058852fc4028780285a1bc62ad23c96664fced508aa">+86/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Edson Michaque <[email protected]>
…ion bugs (#7163) (#7193)

### **User description**
[TT-9234] fixes for graceful shutdown regression bugs (#7163)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-9234"
title="TT-9234" target="_blank">TT-9234</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Graceful shutdown of Gateway</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>Ready for Testing</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC"
title="customer_bug">customer_bug</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC"
title="jira_escalated">jira_escalated</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-candidate-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-candidate-commercial">rel3-2025-candidate-commercial</a>,
<a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-commitment-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-commitment-commercial">rel3-2025-commitment-commercial</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

- added better error handling for case when graceful shutdown timeout is
0
- correctly initialized the graceful shutdown duration

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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


___

### **Description**
- Fixes regression in graceful shutdown timeout handling

- Sets default shutdown duration if config value is zero

- Improves error handling for HTTP server shutdown

- Ensures goroutines finish after shutdown timeout


___

### **Changes diagram**

```mermaid
flowchart LR
  configGo["config/config.go: Set default shutdown duration constant"]
  serverGoTimeout["gateway/server.go: Apply default if timeout is zero"]
  serverGoError["gateway/server.go: Improve error handling for shutdown"]
  serverGoGoroutine["gateway/server.go: Ensure goroutines finish after timeout"]

  configGo -- "uses constant" --> serverGoTimeout
  serverGoTimeout -- "initiates shutdown" --> serverGoError
  serverGoError -- "handles errors" --> serverGoGoroutine
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>config.go</strong><dd><code>Add and use default
graceful shutdown duration constant</code>&nbsp; &nbsp; </dd></summary>
<hr>

config/config.go

<li>Introduced <code>GracefulShutdownDefaultDuration</code> constant (30
seconds)<br> <li> Updated default config to use the new constant for
shutdown timeout


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7163/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Fix graceful shutdown logic
and improve error handling</code>&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Sets default shutdown timeout if config value is zero at
shutdown<br> <li> Improves error handling for HTTP server shutdown
(non-blocking error <br>channel send)<br> <li> Ensures goroutines finish
after shutdown timeout to prevent panic


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7163/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+13/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Ilija Bojanovic <[email protected]>

[TT-9234]:
https://tyktech.atlassian.net/browse/TT-9234?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Fixes regression in graceful shutdown timeout handling

- Sets default shutdown duration if config value is zero

- Improves error handling for HTTP server shutdown

- Ensures goroutines finish after shutdown timeout


___

### **Changes diagram**

```mermaid
flowchart LR
  configGo["config/config.go: Set default shutdown duration constant"]
  serverGoTimeout["gateway/server.go: Apply default if timeout is zero"]
  serverGoError["gateway/server.go: Improve error handling for shutdown"]
  serverGoGoroutine["gateway/server.go: Ensure goroutines finish after timeout"]

  configGo -- "uses constant" --> serverGoTimeout
  serverGoTimeout -- "initiates shutdown" --> serverGoError
  serverGoError -- "handles errors" --> serverGoGoroutine
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>config.go</strong><dd><code>Add and use default
graceful shutdown duration constant</code>&nbsp; &nbsp; </dd></summary>
<hr>

config/config.go

<li>Introduced <code>GracefulShutdownDefaultDuration</code> constant (30
seconds)<br> <li> Updated default config to use the new constant for
shutdown timeout


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7193/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Fix graceful shutdown logic
and improve error handling</code>&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Sets default shutdown timeout if config value is zero at
shutdown<br> <li> Improves error handling for HTTP server shutdown
(non-blocking error <br>channel send)<br> <li> Ensures goroutines finish
after shutdown timeout to prevent panic


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7193/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+13/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: andrei-tyk <[email protected]>
…aviour (#7202) (#7205)

### **User description**
[TT-9234] regression fixes with incorrect behaviour (#7202)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-9234"
title="TT-9234" target="_blank">TT-9234</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Graceful shutdown of Gateway</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Test</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC"
title="customer_bug">customer_bug</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC"
title="jira_escalated">jira_escalated</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-candidate-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-candidate-commercial">rel3-2025-candidate-commercial</a>,
<a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-commitment-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-commitment-commercial">rel3-2025-commitment-commercial</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description
A lost commit caused incorrect behaviour in testing.
<!-- Describe your changes in detail -->



## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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, Enhancement


___

### **Description**
- Fixes regression in graceful shutdown timeout initialization

- Adds default value handling for zero shutdown timeout

- Improves error handling during HTTP server shutdown

- Ensures proper shutdown sequence and prevents premature os.Exit


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Start() initializes Gateway"] -- "Listens for shutdown signal" --> B["Graceful shutdown goroutine"]
  B -- "Checks shutdown timeout, sets default if zero" --> C["Creates shutdown context"]
  C -- "Calls gracefulShutdown()" --> D["Shuts down HTTP servers"]
  D -- "Handles errors, waits for completion" --> E["Signals shutdown complete"]
  E -- "Main goroutine waits for shutdown" --> F["os.Exit(0)"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>config.go</strong><dd><code>Set and use default
graceful shutdown timeout constant</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

config/config.go

<li>Introduced <code>GracefulShutdownDefaultDuration</code> constant<br>
<li> Set default graceful shutdown timeout using the new constant


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7202/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Fix graceful shutdown logic
and error handling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Added channel to coordinate shutdown completion<br> <li> Set default
shutdown timeout if zero before shutdown<br> <li> Improved error
handling in HTTP server shutdown goroutines<br> <li> Ensured main waits
for shutdown before calling os.Exit<br> <li> Prevented panic by waiting
for goroutines after timeout


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7202/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+16/-2</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-9234]:
https://tyktech.atlassian.net/browse/TT-9234?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Fixes regression in graceful shutdown logic

- Adds shutdown completion channel to coordinate exit

- Ensures main goroutine waits for shutdown before exit

- Prevents premature os.Exit and improves shutdown reliability


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Shutdown signal received"] -- "Initiate graceful shutdown" --> B["Graceful shutdown goroutine"]
  B -- "Performs shutdown, closes channel" --> C["shutdownComplete channel"]
  C -- "Main goroutine waits for shutdown" --> D["os.Exit(0)"]
```


___



### **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>server.go</strong><dd><code>Improve graceful shutdown
logic and coordination</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Added <code>shutdownComplete</code> channel to coordinate shutdown
completion<br> <li> Main goroutine now waits for shutdown before calling
os.Exit<br> <li> Moved os.Exit from shutdown goroutine to main
goroutine<br> <li> Prevents premature process exit and ensures graceful
shutdown


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7205/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: andrei-tyk <[email protected]>
### **User description**
[TT-9234] regression fixes (#7207)

<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-9234"
title="TT-9234" target="_blank">TT-9234</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Graceful shutdown of Gateway</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Test</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC"
title="customer_bug">customer_bug</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC"
title="jira_escalated">jira_escalated</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-candidate-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-candidate-commercial">rel3-2025-candidate-commercial</a>,
<a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20rel3-2025-commitment-commercial%20ORDER%20BY%20created%20DESC"

title="rel3-2025-commitment-commercial">rel3-2025-commitment-commercial</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->
Fixes TCP graceful shutdown not being handled.
## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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

[TT-9234]:
https://tyktech.atlassian.net/browse/TT-9234?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Tests, Enhancement


___

### **Description**
- Adds graceful shutdown support for TCP proxies in Gateway.

- Refactors shutdown logic to handle both HTTP servers and TCP proxies.

- Implements connection tracking and shutdown context in TCP proxy.

- Introduces comprehensive tests for TCP proxy shutdown scenarios.


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Gateway shutdown initiated"] -- "Iterate proxies" --> B["HTTP server shutdown"]
  A -- "Iterate proxies" --> C["TCP proxy shutdown"]
  C -- "Set shutdown context, close listener, wait for connections" --> D["Active TCP connections tracked"]
  D -- "All connections closed or timeout" --> E["Shutdown complete"]
  B -- "All HTTP servers closed" --> E
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Add graceful shutdown logic
for TCP proxies in Gateway</code>&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Adds shutdown logic for TCP proxies alongside HTTP servers.<br> <li>
Refactors shutdown code into helper methods for HTTP and TCP.<br> <li>
Updates logs to reflect shutdown of both HTTP and TCP proxies.<br> <li>
Ensures TCP proxies are gracefully shut down during Gateway shutdown.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7213/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+69/-22</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>tcp.go</strong><dd><code>Add connection tracking and
graceful shutdown to TCP Proxy</code></dd></summary>
<hr>

tcp/tcp.go

<li>Implements connection tracking for active TCP connections.<br> <li>
Adds shutdown context and graceful shutdown logic to Proxy.<br> <li>
Ensures all connections are closed or cancelled on shutdown.<br> <li>
Integrates shutdown context checks into connection handling.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7213/files#diff-4964880da1ba03845181b6d43ad9c238e7ff6c8f6a1766deb10d65ebdcc7e4ec">+60/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>server_test.go</strong><dd><code>Add comprehensive
tests for Gateway TCP proxy shutdown</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/server_test.go

<li>Adds tests for Gateway's graceful shutdown with TCP proxies.<br>
<li> Covers scenarios with HTTP, TCP, mixed, and concurrent proxies.<br>
<li> Tests shutdown with active connections and timeouts.<br> <li>
Ensures robust coverage for shutdown logic.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7213/files#diff-d9f006370c9748c09affd99d0a4edeb8f3419057703a67fd70838a764a485696">+397/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>tcp_test.go</strong><dd><code>Add tests for TCP Proxy
graceful shutdown and concurrency</code></dd></summary>
<hr>

tcp/tcp_test.go

<li>Adds unit and integration tests for TCP Proxy shutdown.<br> <li>
Tests connection tracking, shutdown context, and concurrency.<br> <li>
Validates shutdown with active, slow, and cancelled connections.<br>
<li> Ensures thread-safety and correct shutdown behavior.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7213/files#diff-0034cc1ba4ed89ee5d9eb9817110c32f78b2107a8fc4a925adf1ba2af4846050">+424/-0</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: andrei-tyk <[email protected]>
…eadiness check (#7215) (#7220)

### **User description**
[TT-9234] regression fixes for failing mdcb readiness check (#7215)

### **User description**
<!-- Provide a general summary of your changes in the Title above -->

## Description

This PR fixes the health check logic for RPC components when MDCB
(Multi-Data Center Bridge) is operating in emergency mode, ensuring
proper failover behavior during RPC connectivity issues.

## Problem
When MDCB enters emergency mode due to RPC connectivity issues, the
gateway was incorrectly marking RPC health check failures as critical,
causing the entire gateway to report as unhealthy. This prevented proper
failover operation where the gateway should continue serving requests
using cached policies.
## Solution
Modified the isCriticalFailure() function in gateway/health_check.go to
consider RPC emergency mode status when determining if an RPC component
failure is critical.
<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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**
- Fixes critical failure logic for RPC in emergency mode

- Adds unit tests for RPC emergency mode scenarios

- Updates test setup to handle emergency mode toggling

- Ensures correct behavior for RPC health check failures


___

### **Changes diagram**

```mermaid
flowchart LR
  A["isCriticalFailure logic"] -- "add emergency mode check" --> B["RPC component handling"]
  B -- "unit tests for emergency mode" --> C["health_check_test.go"]
```


___



### **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>health_check.go</strong><dd><code>Add emergency mode
check to RPC critical failure logic</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/health_check.go

<li>Adds emergency mode check to RPC critical failure logic<br> <li>
Ensures RPC is not critical in emergency mode


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7215/files#diff-978a2d1427d9209765e541618af10683944c6396df1a6fb8b5221e4f16658a6a">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>health_check_test.go</strong><dd><code>Add and update
tests for RPC emergency mode logic</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/health_check_test.go

<li>Adds tests for RPC critical failure in emergency mode<br> <li>
Updates test cases to toggle emergency mode<br> <li> Imports RPC package
for emergency mode control


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7215/files#diff-08e29946afc7757a9c7baaef04b1a81964640437a684ff6306d1a0c933ac3f6a">+38/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-9234]:
https://tyktech.atlassian.net/browse/TT-9234?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Tests


___

### **Description**
- Fixes RPC critical failure logic to respect emergency mode

- Adds unit tests for RPC emergency mode health check scenarios

- Updates test setup to toggle RPC emergency mode as needed

- Ensures gateway remains healthy in RPC emergency mode


___

### **Changes diagram**

```mermaid
flowchart LR
  A["isCriticalFailure logic"] -- "add emergency mode check" --> B["RPC component handling"]
  B -- "unit tests for emergency mode" --> C["health_check_test.go"]
```


___



### **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>health_check.go</strong><dd><code>Add emergency mode
check to RPC critical failure logic</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/health_check.go

<li>Adds emergency mode check to RPC critical failure logic<br> <li>
Ensures RPC failures are not critical in emergency mode


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7220/files#diff-978a2d1427d9209765e541618af10683944c6396df1a6fb8b5221e4f16658a6a">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>health_check_test.go</strong><dd><code>Add and update
tests for RPC emergency mode logic</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/health_check_test.go

<li>Adds unit tests for RPC emergency mode logic<br> <li> Updates test
cases to toggle emergency mode<br> <li> Imports RPC package for
emergency mode control


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7220/files#diff-08e29946afc7757a9c7baaef04b1a81964640437a684ff6306d1a0c933ac3f6a">+38/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: andrei-tyk <[email protected]>
…ements (#7225) (#7228)

### **User description**
TT-14838 Addressed comments on GW docs improvements (#7225)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14838"
title="TT-14838" target="_blank">TT-14838</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>[5.8.3] Update docs for Gateway changes</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Code Review</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

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


___

### **PR Type**
Documentation


___

### **Description**
- Improved documentation for context variables in middleware

- Clarified gRPC round robin load balancing configuration


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Middleware context variables doc"] -- "clarified wording" --> B["Improved context variables comment"]
  C["gRPC config doc"] -- "added usage details" --> D["Clarified round robin comment"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Clarified context
variables documentation in middleware</code>&nbsp; &nbsp;
</dd></summary>
<hr>

apidef/oas/middleware.go

<li>Updated comment for <code>ContextVariables.Enabled</code> to clarify
middleware <br>access


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7225/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>config.go</strong><dd><code>Clarified gRPC round robin
load balancing documentation</code>&nbsp; &nbsp; </dd></summary>
<hr>

config/config.go

<li>Expanded comment for <code>GRPCRoundRobinLoadBalancing</code> with
usage <br>instructions


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7225/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>


___

### **PR Type**
Documentation


___

### **Description**
- Clarified context variables documentation in middleware

- Expanded gRPC round robin load balancing usage comment


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Context variables comment"] -- "clarified wording" --> B["Improved middleware doc"]
  C["gRPC round robin comment"] -- "added usage details" --> D["Expanded usage instructions"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Clarified context
variables documentation in middleware</code>&nbsp; &nbsp;
</dd></summary>
<hr>

apidef/oas/middleware.go

<li>Clarified the comment for <code>ContextVariables.Enabled</code><br>
<li> Specified which middleware can access context variables


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7228/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>config.go</strong><dd><code>Expanded gRPC round robin
load balancing documentation</code>&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

config/config.go

<li>Expanded comment for <code>GRPCRoundRobinLoadBalancing</code><br>
<li> Added instruction to use <code>dns:///</code> protocol for load
balancing


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7228/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

---------

Co-authored-by: Laurentiu <[email protected]>
Co-authored-by: lghiur <[email protected]>
… when when you enable analytics (#7230) (#7236)

### **User description**
[TT-15251] GW prints body decompression error when when you enable
analytics (#7230)

### **User description**
PR for https://tyktech.atlassian.net/browse/TT-15251

The previous implementation was trying to reassign request body after
extracting stats for a processed GQL request using `respBodyReader`
method. That method fails because request body was already read and this
leads to flood of the following messages:

```
time="Jul 09 13:33:07" level=error msg="Body decompression error:EOF"
time="Jul 09 13:33:07" level=error msg="Body decompression error:EOF"
time="Jul 09 13:33:07" level=error msg="Body decompression error:EOF"
```

I moved the call of `respBodyReader` to fix the bug and this also
enables to extract stats from compressed GQL responses. I added an
integration test for this case.

I used a `io.NopCloser` to reset the reader. Do we need a compressed
copy of the request body? Because we keep `Accept-Encoding` header.
@kofoworola


___

### **PR Type**
Bug fix, Tests


___

### **Description**
- Fixes response body decompression error in analytics recording.

- Moves response body reader assignment before reading body.

- Adds integration test for compressed GraphQL response bodies.

- Updates test utilities to support gzip-encoded responses.


___

### **Changes diagram**

```mermaid
flowchart LR
  A["recordGraphDetails: Assign resp.Body before reading"] -- "Prevents decompression error" --> B["No more 'Body decompression error:EOF' logs"]
  B -- "Enables" --> C["Stats extraction from compressed GQL responses"]
  C -- "Test coverage" --> D["TestAnalyticRecord_GraphStats: gzip test added"]
  D -- "Test utility" --> E["graphqlProxyUpstreamHandler: gzip support"]
```


___



### **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>handler_success.go</strong><dd><code>Fix response body
handling for decompression in analytics</code></dd></summary>
<hr>

gateway/handler_success.go

<li>Assigns <code>resp.Body</code> using <code>respBodyReader</code>
before reading body.<br> <li> Ensures a new reader is set after reading
for further processing.<br> <li> Prevents decompression errors when
analytics are enabled.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7230/files#diff-45135957493eca37f2e3e9a81079577777133c53b27cf95ea2ff0329c05bd006">+5/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>handler_success_test.go</strong><dd><code>Add and
refactor tests for compressed GraphQL responses</code>&nbsp; &nbsp;
</dd></summary>
<hr>

gateway/handler_success_test.go

<li>Adds test case for compressed (gzip) GraphQL response body.<br> <li>
Refactors API definition setup for reuse.<br> <li> Ensures headers can
be set per test case.<br> <li> Improves test consistency and coverage.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7230/files#diff-42a565d872ff6c1f380386f4ee2f75bfa87991b52728a1a9a1772452bb0cd1bb">+32/-9</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>testutil.go</strong><dd><code>Add gzip encoding support
to GraphQL test handler</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/testutil.go

<li>Updates test handler to support gzip-encoded responses.<br> <li>
Sets <code>Content-Encoding: gzip</code> and compresses response if
requested.<br> <li> Maintains backward compatibility for non-gzip
requests.


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7230/files#diff-7aaf6ae49fb8f58a8c99d337fedd15b3e430dd928ed547e425ef429b10d28ce8">+17/-3</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-15251]:
https://tyktech.atlassian.net/browse/TT-15251?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Tests, Enhancement


___

### **Description**
- Fixes response body decompression error in analytics recording.

- Moves response body reader assignment before reading body.

- Adds and refactors tests for compressed GraphQL responses.

- Enhances test utilities to support gzip-encoded responses.


___

### **Changes diagram**

```mermaid
flowchart LR
  A["recordGraphDetails: Assign resp.Body before reading"] -- "Prevents decompression error" --> B["No more 'Body decompression error:EOF' logs"]
  B -- "Enables" --> C["Stats extraction from compressed GQL responses"]
  C -- "Test coverage" --> D["TestAnalyticRecord_GraphStats: gzip test added"]
  D -- "Test utility" --> E["graphqlProxyUpstreamHandler: gzip support"]
```


___



### **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>handler_success.go</strong><dd><code>Fix response body
handling for decompression in analytics</code></dd></summary>
<hr>

gateway/handler_success.go

<li>Assigns <code>resp.Body</code> using <code>respBodyReader</code>
before reading.<br> <li> Ensures a new reader is set after reading for
further processing.<br> <li> Prevents decompression errors when
analytics are enabled.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7236/files#diff-45135957493eca37f2e3e9a81079577777133c53b27cf95ea2ff0329c05bd006">+5/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>handler_success_test.go</strong><dd><code>Add and
refactor tests for compressed GraphQL responses</code>&nbsp; &nbsp;
</dd></summary>
<hr>

gateway/handler_success_test.go

<li>Adds test case for compressed (gzip) GraphQL response body.<br> <li>
Refactors API definition setup for reuse.<br> <li> Allows headers to be
set per test case.<br> <li> Improves test consistency and coverage.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7236/files#diff-42a565d872ff6c1f380386f4ee2f75bfa87991b52728a1a9a1772452bb0cd1bb">+32/-9</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>testutil.go</strong><dd><code>Add gzip encoding support
to GraphQL test handler</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/testutil.go

<li>Updates test handler to support gzip-encoded responses.<br> <li>
Sets <code>Content-Encoding: gzip</code> and compresses response if
requested.<br> <li> Maintains compatibility for non-gzip requests.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7236/files#diff-7aaf6ae49fb8f58a8c99d337fedd15b3e430dd928ed547e425ef429b10d28ce8">+17/-3</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Burak Sezer <[email protected]>
…er API Version check (#7179) (#7242)

### **User description**
[TT-10273] CORS check should be performed after API Version check
(#7179)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-10273"
title="TT-10273" target="_blank">TT-10273</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>[OAS] CORS check should be performed after API Version check</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description
The current implementation applies CORS middleware at the router level,
which executes before the API Version Check middleware in the chain.
This means that for versioned Tyk OAS APIs, the CORS configuration from
the base API is always used, regardless of any version-specific CORS
configurations.

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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)
- [x] 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, Enhancement, Tests


___

### **Description**
- Refactored CORS handling into a dedicated middleware for correct
execution order

- Ensured CORS checks occur after API version checks for OAS APIs

- Updated OAuth endpoint handlers to apply CORS only when enabled

- Added comprehensive unit and integration tests for the new CORS
middleware


___

### **Changes diagram**

```mermaid
flowchart LR
  OldCORS["CORS at router level"] -- "removed" --> X1[""]
  VersionCheck["API Version Check Middleware"] -- "now before" --> NewCORS["CORSMiddleware"]
  NewCORS -- "added to middleware chain" --> APIHandler["API Handler"]
  OAuthEndpoints["OAuth Endpoints"] -- "wrapped with CORS if enabled" --> OAuthCORS["CORS Wrapper"]
  TestsOld["Old CORS tests"] -- "removed" --> X2[""]
  TestsNew["New CORSMiddleware tests"] -- "added" --> CORSMiddleware
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_loader.go</strong><dd><code>Move CORS handling to
middleware chain after version check</code></dd></summary>
<hr>

gateway/api_loader.go

<li>Removed router-level CORS middleware application<br> <li> Added
CORSMiddleware to the middleware chain after version check


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7179/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+1/-16</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_cors.go</strong><dd><code>Add CORSMiddleware
implementation for CORS handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_cors.go

<li>Introduced CORSMiddleware struct and logic<br> <li> Handles CORS
requests as part of middleware chain<br> <li> Returns early for
preflight OPTIONS requests


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7179/files#diff-b83b51e5f6dc341b26ecc1ef7bd72d680f398e599eea327662e2169a3b55f208">+43/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Apply CORS wrapper to OAuth
endpoints when enabled</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Updated OAuth endpoint handlers to wrap with CORS only if
enabled<br> <li> Added createCORSWrapper utility for conditional CORS
wrapping


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7179/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+34/-4</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_loader_test.go</strong><dd><code>Remove outdated
CORS tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/api_loader_test.go

- Removed legacy CORS test function


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7179/files#diff-f696545a659f4d96421b253edef4bcc8da0e7f52120b8f8866d32cbbb7cc1afc">+0/-73</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_cors_test.go</strong><dd><code>Add comprehensive
CORSMiddleware tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_cors_test.go

<li>Added unit tests for CORSMiddleware logic<br> <li> Added integration
tests for CORS behavior on APIs and OAuth endpoints<br> <li> Utility
functions for CORS config and middleware creation


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7179/files#diff-60316be235ab2e13eab4b17dfa535b441db3c29d388c433cca7d6fbe4d26c3a0">+157/-0</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-10273]:
https://tyktech.atlassian.net/browse/TT-10273?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement, Tests


___

### **Description**
- Refactored CORS handling into a dedicated middleware after version
check

- Ensured CORS checks use version-specific configuration for OAS APIs

- Updated OAuth endpoint handlers to conditionally apply CORS

- Added comprehensive unit and integration tests for new CORS middleware


___

### **Changes diagram**

```mermaid
flowchart LR
  OldCORS["CORS at router level"] -- "removed" --> X1[""]
  VersionCheck["API Version Check Middleware"] -- "now before" --> NewCORS["CORSMiddleware"]
  NewCORS -- "added to middleware chain" --> APIHandler["API Handler"]
  OAuthEndpoints["OAuth Endpoints"] -- "wrapped with CORS if enabled" --> OAuthCORS["CORS Wrapper"]
  TestsOld["Old CORS tests"] -- "removed" --> X2[""]
  TestsNew["New CORSMiddleware tests"] -- "added" --> CORSMiddleware
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_loader.go</strong><dd><code>Move CORS handling to
middleware chain after version check</code></dd></summary>
<hr>

gateway/api_loader.go

<li>Removed router-level CORS middleware application<br> <li> Added
CORSMiddleware to middleware chain after version check


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+1/-16</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_cors.go</strong><dd><code>Add CORSMiddleware
implementation for CORS handling</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_cors.go

<li>Introduced CORSMiddleware struct and logic<br> <li> Handles CORS
requests as part of middleware chain<br> <li> Returns early for
preflight OPTIONS requests


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-b83b51e5f6dc341b26ecc1ef7bd72d680f398e599eea327662e2169a3b55f208">+43/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>server.go</strong><dd><code>Apply CORS wrapper to OAuth
endpoints when enabled</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/server.go

<li>Updated OAuth endpoint handlers to wrap with CORS only if
enabled<br> <li> Added createCORSWrapper utility for conditional CORS
wrapping


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+34/-4</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api_loader_test.go</strong><dd><code>Remove outdated
CORS tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/api_loader_test.go

- Removed legacy CORS test function


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-f696545a659f4d96421b253edef4bcc8da0e7f52120b8f8866d32cbbb7cc1afc">+0/-73</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_cors_test.go</strong><dd><code>Add comprehensive
CORSMiddleware tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_cors_test.go

<li>Added unit tests for CORSMiddleware logic<br> <li> Added integration
tests for CORS behavior on APIs and OAuth endpoints<br> <li> Utility
functions for CORS config and middleware creation


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-60316be235ab2e13eab4b17dfa535b441db3c29d388c433cca7d6fbe4d26c3a0">+187/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>reverse_proxy_test.go</strong><dd><code>Remove CORS
header checks from GraphQL passthrough test</code>&nbsp; &nbsp;
</dd></summary>
<hr>

gateway/reverse_proxy_test.go

<li>Removed CORS header assertions from GraphQL options passthrough test


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7242/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+0/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

Co-authored-by: Maciej Miś <[email protected]>
… in Tyk OAS API Debugger (#7208) (#7253)

### **User description**
[TT-14914] No response middleware information in Tyk OAS API Debugger
(#7208)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14914"
title="TT-14914" target="_blank">TT-14914</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td> No response middleware information in Tyk OAS API Debugger</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Code Review</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description
Short fix that @radkrawczyk managed to find. 
XRateLimit* already headers present in mocked-response. In addition smal
refatoring.
Code responsible for sending those headers placed in one method.

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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, Enhancement


___

### **Description**
- Centralized logic for sending rate-limit headers in responses

- Fixed missing rate-limit headers in mocked and cached responses

- Refactored code to use new `sendRateLimitHeaders` method

- Improved maintainability by removing duplicate header logic


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Duplicate rate-limit header logic"] -- "Refactored to" --> B["sendRateLimitHeaders method in APISpec"]
  B -- "Used by" --> C["Mock response middleware"]
  B -- "Used by" --> D["Redis cache middleware"]
  B -- "Used by" --> E["Virtual endpoint forced response"]
  B -- "Used by" --> F["Reverse proxy response handler"]
  C -- "Ensures" --> G["Consistent rate-limit headers in mocked responses"]
  D -- "Ensures" --> H["Consistent rate-limit headers in cached responses"]
  E -- "Ensures" --> I["Consistent rate-limit headers in forced responses"]
  F -- "Ensures" --> J["Consistent rate-limit headers in proxied responses"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>model_apispec.go</strong><dd><code>Add and use
centralized rate-limit header sender</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/model_apispec.go

<li>Added <code>sendRateLimitHeaders</code> method to centralize
rate-limit header <br>logic<br> <li> Utilizes session data to set
X-RateLimit headers on responses


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-80c49b9bdb411a3d5a4706ec3ff138ef44154d0306040c19eba1cb5559f199d6">+22/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_redis_cache.go</strong><dd><code>Use centralized
rate-limit headers in cache middleware</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/mw_redis_cache.go

<li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures cached responses
include consistent rate-limit headers


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-6266e0dbd16cef89e6de86a2c893114ba07799c804e2138172f9f94b08cdded8">+1/-9</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_virtual_endpoint.go</strong><dd><code>Use
centralized rate-limit headers in virtual endpoint
responses</code></dd></summary>
<hr>

gateway/mw_virtual_endpoint.go

<li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures forced responses
include quota headers


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-daf72ac3b29609a9f2a77cccf648f91ba62b2ad977a7c5a44602c72b2a28b2e5">+1/-10</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>reverse_proxy.go</strong><dd><code>Use centralized
rate-limit headers in reverse proxy responses</code></dd></summary>
<hr>

gateway/reverse_proxy.go

<li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures proxied responses
include quota headers


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+1/-9</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>mw_mock_response.go</strong><dd><code>Add rate-limit
headers to mocked responses</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/mw_mock_response.go

<li>Calls <code>sendRateLimitHeaders</code> to add rate-limit headers to
mocked <br>responses<br> <li> Ensures mocked responses include quota
information


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Miscellaneous</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Minor formatting
adjustment</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/middleware.go

- Minor formatting change (added blank line)
- No functional changes


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7208/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>

[TT-14914]:
https://tyktech.atlassian.net/browse/TT-14914?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Centralized rate-limit header logic in `sendRateLimitHeaders` method

- Ensured rate-limit headers are added to mocked, cached, forced, and
proxied responses

- Removed duplicate header-setting code from multiple middleware
components

- Minor formatting improvement in middleware code


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["Duplicate rate-limit header logic"] -- "Refactored to" --> B["sendRateLimitHeaders method in APISpec"]
  B -- "Used by" --> C["Mock response middleware"]
  B -- "Used by" --> D["Redis cache middleware"]
  B -- "Used by" --> E["Virtual endpoint forced response"]
  B -- "Used by" --> F["Reverse proxy response handler"]
  C -- "Ensures" --> G["Consistent rate-limit headers in mocked responses"]
  D -- "Ensures" --> H["Consistent rate-limit headers in cached responses"]
  E -- "Ensures" --> I["Consistent rate-limit headers in forced responses"]
  F -- "Ensures" --> J["Consistent rate-limit headers in proxied responses"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>model_apispec.go</strong><dd><code>Add and use
centralized rate-limit header sender</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/model_apispec.go

<ul><li>Added <code>sendRateLimitHeaders</code> method to centralize
rate-limit header <br>logic<br> <li> Uses session data to set
X-RateLimit headers on responses</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-80c49b9bdb411a3d5a4706ec3ff138ef44154d0306040c19eba1cb5559f199d6">+21/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_redis_cache.go</strong><dd><code>Use centralized
rate-limit headers in cache middleware</code>&nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/mw_redis_cache.go

<ul><li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures cached responses
include consistent rate-limit headers</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-6266e0dbd16cef89e6de86a2c893114ba07799c804e2138172f9f94b08cdded8">+1/-9</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_virtual_endpoint.go</strong><dd><code>Use
centralized rate-limit headers in virtual endpoint
responses</code></dd></summary>
<hr>

gateway/mw_virtual_endpoint.go

<ul><li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures forced responses
include quota headers</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-daf72ac3b29609a9f2a77cccf648f91ba62b2ad977a7c5a44602c72b2a28b2e5">+1/-10</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>reverse_proxy.go</strong><dd><code>Use centralized
rate-limit headers in reverse proxy responses</code></dd></summary>
<hr>

gateway/reverse_proxy.go

<ul><li>Replaces inline rate-limit header logic with
<code>sendRateLimitHeaders</code><br> <li> Ensures proxied responses
include quota headers</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+1/-9</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>mw_mock_response.go</strong><dd><code>Add rate-limit
headers to mocked responses</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/mw_mock_response.go

<ul><li>Calls <code>sendRateLimitHeaders</code> to add rate-limit
headers to mocked <br>responses<br> <li> Ensures mocked responses
include quota information</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-fa778ebf662b147d9693791799966dbd20fca6eb5dc98b2e7264230b4e0cbfbd">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Miscellaneous</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Minor formatting
adjustment</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/middleware.go

- Minor formatting change (added blank line)
- No functional changes


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7253/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Co-authored-by: Yaroslav Kotsur <[email protected]>
…ms with servers (#7233) (#7260)

### **User description**
[TT-11244] Custom domain regex causing problems with servers (#7233)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-11244"
title="TT-11244" target="_blank">TT-11244</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>Custom domain regex causing problems with servers</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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, Enhancement, Tests


___

### **Description**
- Fixed handling of custom domain regex in OAS server URLs.

- Added robust parsing for server URLs with regex and variables.

- Introduced `RemoveServer` method to remove servers by normalized URL.

- Enhanced and expanded tests for server URL parsing and server
management.


___

### Diagram Walkthrough


```mermaid
flowchart LR
  oasutil["oasutil/servers.go: Server URL parser & helpers"]
  oas["apidef/oas/oas.go: AddServers/RemoveServer logic"]
  oastest["apidef/oas/oas_test.go: AddServers & RemoveServer tests"]
  gateway["gateway/api.go: Integrate AddServers error handling"]
  oasutiltest["internal/oasutil/servers_test.go: Parser unit tests"]

  oasutil -- "used by" --> oas
  oas -- "tested by" --> oastest
  oasutil -- "tested by" --> oasutiltest
  gateway -- "calls" --> oas
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>oas.go</strong><dd><code>Refactor and fix OAS server
URL add/remove logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/oas.go

<ul><li>Added <code>RemoveServer</code> method for removing servers by
normalized URL.<br> <li> Refactored <code>AddServers</code> to use new
server URL parser and handle <br>regex/variables.<br> <li> Updated
<code>AddServers</code> to return errors on invalid input.<br> <li>
Improved handling of server variables and normalization.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7233/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+36/-7</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>servers.go</strong><dd><code>Add robust OAS server URL
parser utility</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

internal/oasutil/servers.go

<ul><li>Introduced server URL parser handling regex and variables.<br>
<li> Added error types for parsing issues and collisions.<br> <li>
Provided normalization and variable extraction logic.<br> <li> Exported
<code>ParseServerUrl</code> for external use.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7233/files#diff-98dd06199bf9992e099563df9150f18cb38094f4dae3299f33c5330722ddac3d">+162/-0</a>&nbsp;
</td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>oas_test.go</strong><dd><code>Expand and improve OAS
server management tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/oas_test.go

<ul><li>Updated <code>TestOAS_AddServers</code> to test new server URL
parsing and <br>normalization.<br> <li> Added
<code>Test_RemoveServer</code> for new removal logic and edge cases.<br>
<li> Improved assertions for server variables and error handling.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7233/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+103/-42</a></td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>servers_test.go</strong><dd><code>Add unit tests for
OAS server URL parser</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

internal/oasutil/servers_test.go

<ul><li>Added comprehensive unit tests for server URL parser.<br> <li>
Covered positive and negative cases, including regex and
collisions.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7233/files#diff-4a274e0f05feb520d7ff68fb48a7a28020ea7525820ac8105f4c898854a19af8">+91/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api.go</strong><dd><code>Integrate AddServers error
handling in API creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/api.go

<ul><li>Updated OAS API add handler to handle errors from
<code>AddServers</code>.<br> <li> Returns HTTP 400 if server URL parsing
fails.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7233/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+4/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

[TT-11244]:
https://tyktech.atlassian.net/browse/TT-11244?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement, Tests


___

### **Description**
- Fixed parsing and normalization of OAS server URLs with
regex/variables.

- Added robust utility for parsing and managing OAS server URLs.

- Introduced RemoveServer method for removing servers by normalized URL.

- Expanded and improved tests for server URL parsing and server
management.


___

### Diagram Walkthrough


```mermaid
flowchart LR
  oasutil["oasutil/servers.go: Server URL parser & helpers"]
  oas["apidef/oas/oas.go: AddServers/RemoveServer logic"]
  oastest["apidef/oas/oas_test.go: AddServers & RemoveServer tests"]
  gateway["gateway/api.go: Integrate AddServers error handling"]
  oasutiltest["internal/oasutil/servers_test.go: Parser unit tests"]

  oasutil -- "used by" --> oas
  oas -- "tested by" --> oastest
  oasutil -- "tested by" --> oasutiltest
  gateway -- "calls" --> oas
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>oas.go</strong><dd><code>Refactor and fix OAS server
URL add/remove logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/oas.go

<ul><li>Added RemoveServer method for removing servers by normalized
URL.<br> <li> Refactored AddServers to use new server URL parser and
handle <br>regex/variables.<br> <li> AddServers now returns errors on
invalid input.<br> <li> Improved handling of server variables and
normalization.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7260/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+36/-7</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>servers.go</strong><dd><code>Add robust OAS server URL
parser utility</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

internal/oasutil/servers.go

<ul><li>Introduced server URL parser handling regex and variables.<br>
<li> Added error types for parsing issues and collisions.<br> <li>
Provided normalization and variable extraction logic.<br> <li> Exported
ParseServerUrl for external use.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7260/files#diff-98dd06199bf9992e099563df9150f18cb38094f4dae3299f33c5330722ddac3d">+162/-0</a>&nbsp;
</td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>oas_test.go</strong><dd><code>Expand and improve OAS
server management tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apidef/oas/oas_test.go

<ul><li>Updated TestOAS_AddServers to test new server URL parsing and
<br>normalization.<br> <li> Added Test_RemoveServer for new removal
logic and edge cases.<br> <li> Improved assertions for server variables
and error handling.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7260/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+103/-42</a></td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>servers_test.go</strong><dd><code>Add unit tests for
OAS server URL parser</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

internal/oasutil/servers_test.go

<ul><li>Added comprehensive unit tests for server URL parser.<br> <li>
Covered positive and negative cases, including regex and
collisions.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7260/files#diff-4a274e0f05feb520d7ff68fb48a7a28020ea7525820ac8105f4c898854a19af8">+91/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api.go</strong><dd><code>Integrate AddServers error
handling in API creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/api.go

<ul><li>Updated OAS API add handler to handle errors from
AddServers.<br> <li> Returns HTTP 400 if server URL parsing fails.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7260/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+4/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Co-authored-by: Yaroslav Kotsur <[email protected]>
…me values to decimals causing a schema problem (#7256) (#7264)

### **User description**
[TT-14370] [OAS] ReadableDuration converts some values to decimals
causing a schema problem (#7256)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-14370"
title="TT-14370" target="_blank">TT-14370</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>[OAS] ReadableDuration converts some values to decimals causing a
schema problem</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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**
- Fixes duration serialization to avoid decimal values in JSON.

- Implements custom formatting for `ReadableDuration` output.

- Adds new test cases for composite durations (e.g., "1m30s").

- Updates expected JSON outputs in tests for consistency.


___

### Diagram Walkthrough


```mermaid
flowchart LR
  durationGo["duration.go: Add custom format for ReadableDuration"] -- "uses" --> durationTestGo["duration_test.go: Update & add tests for new format"]
  durationGo -- "fixes" --> "JSON serialization issue"
  durationTestGo -- "validates" --> "Correct output for various durations"
```



<details> <summary><h3> File Walkthrough</h3></summary>

<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>duration.go</strong><dd><code>Custom formatting for
ReadableDuration JSON serialization</code></dd></summary>
<hr>

internal/time/duration.go

<ul><li>Adds a custom <code>format()</code> method for
<code>ReadableDuration</code>.<br> <li> Ensures JSON serialization
outputs only integer values and valid <br>patterns.<br> <li> Introduces
constants and a conversion table for time units.<br> <li> Refactors
<code>MarshalJSON</code> to use the new formatting logic.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7256/files#diff-6e8ef3118f84cbcc935f27d5a3ad5f4eb86eb22728400e9322c9b796b9d8d855">+53/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>duration_test.go</strong><dd><code>Update and expand
tests for duration serialization</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/time/duration_test.go

<ul><li>Updates expected JSON output for minute-based durations.<br>
<li> Adds new test for composite durations (e.g., "1m30s").<br> <li>
Ensures tests align with new serialization logic.</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7256/files#diff-71942cdc77128266498b62e712f82d0c63bbb39d236fe9e6677f49080c28cea1">+9/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

[TT-14370]:
https://tyktech.atlassian.net/browse/TT-14370?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Tests


___

### **Description**
- Fixes JSON serialization of `ReadableDuration` to avoid decimals.

- Implements custom formatting for composite durations (e.g., "1m30s").

- Updates and expands unit tests for new duration format.

- Ensures negative and complex durations are handled correctly.


___

### Diagram Walkthrough


```mermaid
flowchart LR
  durationGo["duration.go: Custom format for ReadableDuration"] -- "used by" --> durationTestGo["duration_test.go: Expanded tests"]
  durationGo -- "fixes" --> jsonSerialization["JSON serialization issue"]
  durationTestGo -- "validates" --> correctOutput["Correct output for various durations"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<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>duration.go</strong><dd><code>Custom formatting and
serialization fix for ReadableDuration</code></dd></summary>
<hr>

internal/time/duration.go

<ul><li>Adds custom <code>format()</code> method for
<code>ReadableDuration</code>.<br> <li> Refactors
<code>MarshalJSON</code> to use new formatting logic.<br> <li>
Introduces constants and conversion table for time units.<br> <li>
Handles negative and composite durations.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7264/files#diff-6e8ef3118f84cbcc935f27d5a3ad5f4eb86eb22728400e9322c9b796b9d8d855">+58/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>duration_test.go</strong><dd><code>Update and expand
tests for duration serialization</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/time/duration_test.go

<ul><li>Updates expected JSON output for minute-based durations.<br>
<li> Adds new tests for composite and negative durations.<br> <li>
Ensures tests align with new serialization logic.</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7264/files#diff-71942cdc77128266498b62e712f82d0c63bbb39d236fe9e6677f49080c28cea1">+22/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Co-authored-by: Yaroslav Kotsur <[email protected]>
…to create version without `new_version_name` (#7244) (#7258)

### **User description**
[TT-7523] [OAS Versioning] Gateway CE allows to create version without
`new_version_name` (#7244)

### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-7523"
title="TT-7523" target="_blank">TT-7523</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>[OAS Versioning] Gateway CE allows to create version without
`new_version_name`</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"

src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
<td><a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC"
title="codilime_refined">codilime_refined</a>, <a

href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20version-tyk-oas%20ORDER%20BY%20created%20DESC"
title="version-tyk-oas">version-tyk-oas</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description
Gateway API accepts requests to create new API version even if the new
version name parameter is not specified.
This PR contains fix for this issue along with example, how a shared
library could be used to extract common code.

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## 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)
- [x] 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, Enhancement, Tests


___

### **Description**
- Enforces validation for `new_version_name` when creating API versions

- Returns HTTP 422 if `new_version_name` is missing in versioning
requests

- Refactors versioning logic into a shared library
(`lib/apidef/version.go`)

- Adds comprehensive unit tests for versioning logic in shared library


___

### Diagram Walkthrough


```mermaid
flowchart LR
  apiHandler["Gateway API Versioning Handler"]
  sharedLib["Shared Versioning Library (lib/apidef/version.go)"]
  validation["Validation for new_version_name"]
  error422["Returns HTTP 422 on missing new_version_name"]
  tests["Unit Tests for Versioning Logic"]

  apiHandler -- "Uses" --> sharedLib
  sharedLib -- "Performs" --> validation
  validation -- "On error" --> error422
  sharedLib -- "Covered by" --> tests
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant

files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api.go</strong><dd><code>Enforce and refactor API
versioning logic using shared library</code></dd></summary>
<hr>

gateway/api.go

<ul><li>Integrates shared versioning library for parameter handling and
<br>validation<br> <li> Enforces <code>new_version_name</code> presence,
returning HTTP 422 if missing<br> <li> Refactors versioning logic to use
new shared library functions<br> <li> Simplifies and clarifies API
versioning code path</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7244/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+46/-56</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>version.go</strong><dd><code>Add shared library for API
versioning logic and validation</code></dd></summary>
<hr>

lib/apidef/version.go

<ul><li>Introduces shared library for API versioning parameter handling
and <br>validation<br> <li> Implements strict validation for required
parameters (e.g., <br><code>new_version_name</code>)<br> <li> Provides
utility functions for configuring version definitions<br> <li>
Centralizes versioning logic for reuse and maintainability</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7244/files#diff-9e698644fcca1a469641d3cd92ad309f640e4f8474b6d4fbe9478123516f180d">+181/-0</a>&nbsp;
</td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>version_test.go</strong><dd><code>Add unit tests for
shared versioning library</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

lib/apidef/version_test.go

<ul><li>Adds comprehensive unit tests for versioning parameter logic and
<br>validation<br> <li> Tests error handling for missing and invalid
parameters<br> <li> Verifies configuration of version definitions via
shared library<br> <li> Ensures robustness of new versioning logic</ul>


</details>


  </td>
<td><a

href="https://github.com/TykTechnologies/tyk/pull/7244/files#diff-c67df2864ba1a068ada18f017570b6190f6af0e1f1515f3110a81f59a7da42e6">+181/-0</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

[TT-7523]:
https://tyktech.atlassian.net/browse/TT-7523?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


___

### **PR Type**
Bug fix, Enhancement, Tests


___

### **Description**
- Enforces validation for `new_version_name` in API version creation

- Returns HTTP 422 if `new_version_name` is missing in versioning
requests

- Refactors versioning logic into a shared library
(`lib/apidef/version.go`)

- Adds comprehensive unit tests for versioning logic and validation


___

### Diagram Walkthrough


```mermaid
flowchart LR
  apiHandler["Gateway API Versioning Handler"]
  sharedLib["Shared Versioning Library (lib/apidef/version.go)"]
  validation["Validation for new_version_name"]
  error422["Returns HTTP 422 on missing new_version_name"]
  tests["Unit Tests for Versioning Logic"]

  apiHandler -- "Uses" --> sharedLib
  sharedLib -- "Performs" --> validation
  validation -- "On error" --> error422
  sharedLib -- "Covered by" --> tests
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>api.go</strong><dd><code>Enforce and refactor API
versioning logic using shared library</code></dd></summary>
<hr>

gateway/api.go

<ul><li>Integrates shared versioning library for parameter handling and
<br>validation<br> <li> Enforces presence of
<code>new_version_name</code>, returning HTTP 422 if missing<br> <li>
Refactors versioning logic to use new shared library functions<br> <li>
Simplifies and clarifies API versioning code path</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7258/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+36/-57</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>version.go</strong><dd><code>Add shared library for API
versioning logic and validation</code></dd></summary>
<hr>

lib/apidef/version.go

<ul><li>Introduces shared library for API versioning parameter handling
and <br>validation<br> <li> Implements strict validation for required
parameters (e.g., <br><code>new_version_name</code>)<br> <li> Provides
utility functions for configuring version definitions<br> <li>
Centralizes versioning logic for reuse and maintainability</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7258/files#diff-9e698644fcca1a469641d3cd92ad309f640e4f8474b6d4fbe9478123516f180d">+198/-0</a>&nbsp;
</td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>version_test.go</strong><dd><code>Add unit tests for
shared versioning library</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

lib/apidef/version_test.go

<ul><li>Adds comprehensive unit tests for versioning parameter logic and
<br>validation<br> <li> Tests error handling for missing and invalid
parameters<br> <li> Verifies configuration of version definitions via
shared library<br> <li> Ensures robustness of new versioning logic</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7258/files#diff-c67df2864ba1a068ada18f017570b6190f6af0e1f1515f3110a81f59a7da42e6">+188/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>api_test.go</strong><dd><code>Update API versioning
tests for new validation logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/api_test.go

<ul><li>Updates assertions in API versioning tests to reflect new
logic<br> <li> Ensures correct version count after version creation</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7258/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+4/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Co-authored-by: Maciej Miś <[email protected]>
### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-15196"
title="TT-15196" target="_blank">TT-15196</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
      <td>[5.9.0] Update docs for Gateway changes</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"
src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Dev</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

This PR fixes an issue with generated docs.


___

### **PR Type**
Documentation


___

### **Description**
- Added code block markers to TLSTransport documentation example

- Improved clarity and formatting of GoDoc comments


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["TLSTransport GoDoc"] -- "add code block markers" --> B["Improved documentation formatting"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>upstream.go</strong><dd><code>Add code block markers to
TLSTransport GoDoc example</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

apidef/oas/upstream.go

<ul><li>Added triple backticks to TLSTransport struct GoDoc example<br>
<li> Enhanced documentation formatting for clarity</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7277/files#diff-7b0941c7f37fe5a2a23047e0822a65519ca11c371660f36555b59a60f000e3f4">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___
@buger
Copy link
Member

buger commented Aug 7, 2025

💔 The detected issue is not in one of the allowed statuses 💔

Detected Status Open
Allowed Statuses In Dev,In Code Review,Ready for Testing,In Test,In Progress,In Review ✔️

Please ensure your jira story is in one of the allowed statuses

Copy link
Contributor

github-actions bot commented Aug 7, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Logic Change

The /hello endpoint now always returns HTTP 200, regardless of health check results. Reviewers should validate that this change aligns with the intended liveness semantics and does not negatively impact monitoring or alerting systems that rely on non-200 responses for failures.

w.WriteHeader(http.StatusOK)
err := json.NewEncoder(w).Encode(res)
Error Logging Consistency

The readiness handler now logs JSON encoding errors, matching the liveness handler. Confirm that this logging is sufficient and does not expose sensitive information in logs.

err := json.NewEncoder(w).Encode(res)
if err != nil {
	mainLog.Warning(fmt.Sprintf("[Readiness] Could not encode response, error: %s", err.Error()))
}

Copy link
Contributor

github-actions bot commented Aug 7, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle empty health checks correctly

The use of case len(checks): in the switch statement may never match, since
failCount can only reach len(checks) if all checks fail. However, if checks is
empty, this logic will incorrectly set the status to Fail. Add an explicit check for
zero checks to avoid misclassifying the health status when there are no checks.

gateway/health_check.go [192-209]

 for _, v := range checks {
 	if v.Status == Fail {
 		failCount++
 	}
 }
 
 var status HealthCheckStatus
 
-switch failCount {
-case 0:
-	status = Pass
-
-case len(checks):
-	status = Fail
-
-default:
+if len(checks) == 0 {
 	status = Warn
+} else {
+	switch failCount {
+	case 0:
+		status = Pass
+	case len(checks):
+		status = Fail
+	default:
+		status = Warn
+	}
 }
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a subtle bug: if checks is empty, the current logic would incorrectly set status to Fail. The improved code ensures that an empty set of checks results in a Warn status, which is more appropriate and prevents misleading health reporting. This is a significant correctness fix.

Medium

Copy link
Contributor

github-actions bot commented Aug 7, 2025

API Changes

no api changes detected

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Code Review: Reverting /hello endpoint to always return 200 status code

Summary

This PR reverts the /hello (liveness) endpoint to always return HTTP 200 status code, regardless of the health check results. The changes are focused on the gateway/health_check.go file and align with the PR description.

Key Changes

  1. Always returning HTTP 200 for liveness endpoint

    • Changed from dynamic status code to always returning http.StatusOK
    • Health check results are still included in the response body
  2. Simplified health status calculation

    • Removed calls to evaluateHealthChecks and determineHealthStatus functions
    • Added direct calculation of failCount by iterating through checks
    • Added a simple switch statement to determine the status based on failCount
  3. Added error logging for readiness handler

    • Added JSON encoding error logging in the readiness handler to match the liveness handler

Potential Issues

1. Empty health checks edge case

switch failCount {
case 0:
    status = Pass
case len(checks):
    status = Fail
default:
    status = Warn
}

If checks is empty (len(checks) == 0), then failCount would be 0, and the status would be set to Pass. However, if checks is empty, the case len(checks): would also match, potentially leading to incorrect status determination. Consider adding an explicit check for empty health checks:

if len(checks) == 0 {
    status = Warn
} else {
    switch failCount {
    case 0:
        status = Pass
    case len(checks):
        status = Fail
    default:
        status = Warn
    }
}

2. Unused functions

The functions determineHealthStatus, evaluateHealthChecks, and isCriticalFailure are still present in the code but are no longer used by the liveCheckHandler. If they're not used elsewhere, consider removing them to clean up the code.

Impact Analysis

  1. Monitoring systems: Systems monitoring the HTTP status code of the /hello endpoint will need to be updated to look at the response body content instead of relying on non-200 status codes for failure detection.

  2. Kubernetes liveness probes: If Kubernetes liveness probes are configured to check the /hello endpoint, they will now always succeed regardless of the actual health status. This could lead to unhealthy pods remaining in service.

Conclusion

The changes align with the PR description and successfully revert the /hello endpoint to always return HTTP 200. The code is generally well-structured, but there's a potential edge case with empty health checks that should be addressed. Additionally, consider removing unused functions if they're not needed elsewhere.


Tip: Mention me again using /probe <request>.
Powered by Probe AI

@mativm02 mativm02 changed the base branch from release-5.9 to release-5.9.1 August 7, 2025 15:20
@mativm02 mativm02 requested a review from a team as a code owner August 7, 2025 15:20
@mativm02 mativm02 closed this Aug 7, 2025
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