-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[TT-7524] [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCH #7261
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
[TT-7524] [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCH #7261
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
API Changes no api changes detected |
🚀 Performance Snapshot
## Performance Impact AnalysisThe PR adds a new The implementation uses ## Critical AreasThe changes affect the API definition update path, specifically when using PATCH operations on OAS APIs. This is not in the critical request handling path, as it only impacts API management operations, not runtime request processing. The operation cleanup happens during API updates, which are infrequent administrative actions. The implementation is efficient for the expected scale of operations in a typical API definition (usually tens of operations, not thousands), making the linear search acceptable. ## Optimization RecommendationsThe current implementation is appropriate for the expected scale. If future APIs contain hundreds of operations, consider:
However, these optimizations are likely unnecessary for typical API definitions with a modest number of operations. ## Summary
Tip: Mention me again using |
🚦 Connectivity Review Snapshot
## Connectivity Assessment
## Test Coverage Validation
## Security & Performance Impact
## Summary & Recommendations
Tip: Mention me again using |
📦 Impact Review Snapshot
## Impact AssessmentThis PR fixes an issue where PATCH operations on OAS APIs via the Gateway API didn't properly update the Tyk vendor extension (x-tyk-api-gateway), causing out-of-sync API definitions. The fix adds a The change is primarily internal to the Gateway and doesn't modify any API schemas or interfaces. It ensures that the Gateway behaves consistently with the Dashboard when handling OAS API updates, which is important for downstream repositories that interact with both components. ## Required UpdatesNo immediate updates are required in downstream repositories as this is a bug fix that doesn't change any schemas or interfaces. However, repositories that interact with both Gateway and Dashboard should be aware of the improved consistency:
## Compatibility ConcernsThis change has no backward compatibility issues. It's a bug fix that ensures the Gateway properly updates the Tyk vendor extension during PATCH operations, which aligns with expected behavior. The fix ensures that obsolete operations are properly removed from the Tyk extension, which was already the expected behavior but wasn't working correctly. The change is transparent to API consumers and doesn't modify any public interfaces or schemas. ## Summary & Recommendations
Tip: Mention me again using |
Error during chat processing: Error: Failed to get response from AI model during iteration 14. terminated Tip: Mention me again using |
…-from-dashboard-for-middleware-and-patch
🛡️ Security Snapshot
## Security Impact AnalysisThe PR adds a ## Identified VulnerabilitiesNo vulnerabilities were identified in this change. The implementation:
## Security RecommendationsThe implementation is secure as-is. The only minor consideration would be to ensure that the ## OWASP ComplianceThis change doesn't impact any OWASP Top 10 categories directly. It's a maintenance function that ensures data consistency between API definitions and their middleware configurations. The change doesn't modify authentication, authorization, input validation, or any other security-critical components. ## Summary
Tip: Mention me again using |
🚦 Connectivity Review Snapshot
## Connectivity Assessment
## Test Coverage Validation
## Security & Performance Impact
## Summary & Recommendations
Tip: Mention me again using |
🚀 Performance Snapshot
## Performance Impact AnalysisThe PR adds a new The implementation uses ## Critical AreasThe changes affect the API definition update path, specifically when using PATCH operations on OAS APIs. This is not in the critical request handling path, as it only impacts API management operations, not runtime request processing. The operation cleanup happens during API updates, which are infrequent administrative actions. The implementation is efficient for the expected scale of operations in a typical API definition (usually tens of operations, not thousands), making the linear search acceptable. ## Optimization RecommendationsThe current implementation is appropriate for the expected scale. If future APIs contain hundreds of operations, consider:
However, these optimizations are likely unnecessary for typical API definitions with a modest number of operations. ## Summary
Tip: Mention me again using |
Analysis of PR #7261: [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCHThis PR addresses an issue where updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API does not properly update the Tyk vendor extension (x-tyk-api-gateway), resulting in the API description being out of sync or invalid. Key Changes
Problem ContextBefore this fix, when updating an API using PATCH operations via the Gateway API, the Tyk vendor extension (x-tyk-api-gateway) wasn't properly updated to remove operations that were no longer present in the API definition. This resulted in:
Implementation DetailsThe implementation uses a two-phase approach:
This approach avoids modifying the map during iteration and uses Impact and Benefits
The changes are focused and minimal, with appropriate test coverage to verify the functionality. This fix ensures that when API paths are removed or modified via PATCH operations, the corresponding operations in the Tyk extension are properly cleaned up, maintaining consistency between the API definition and its Tyk extension. Tip: Mention me again using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…-from-dashboard-for-middleware-and-patch
📦 Impact Review Snapshot
## Impact AssessmentThis PR fixes an issue where PATCH operations on OAS APIs via the Gateway API didn't properly update the Tyk vendor extension (x-tyk-api-gateway), causing out-of-sync API definitions. The fix adds a The change is primarily internal to the Gateway and doesn't modify any API schemas or interfaces. It ensures that the Gateway behaves consistently with the Dashboard when handling OAS API updates, which is important for downstream repositories that interact with both components. ## Required UpdatesNo immediate updates are required in downstream repositories as this is a bug fix that doesn't change any schemas or interfaces. However, repositories that interact with both Gateway and Dashboard should be aware of the improved consistency:
## Compatibility ConcernsThis change has no backward compatibility issues. It's a bug fix that ensures the Gateway properly updates the Tyk vendor extension during PATCH operations, which aligns with expected behavior. The fix ensures that obsolete operations are properly removed from the Tyk extension, which was already the expected behavior but wasn't working correctly. The change is transparent to API consumers and doesn't modify any public interfaces or schemas. ## Summary & Recommendations
Tip: Mention me again using |
🛡️ Security Snapshot
## Security Impact AnalysisThe PR adds a ## Identified VulnerabilitiesNo vulnerabilities were identified in this change. The implementation:
## Security RecommendationsThe implementation is secure as-is. The only minor consideration would be to ensure that the ## OWASP ComplianceThis change doesn't impact any OWASP Top 10 categories directly. It's a maintenance function that ensures data consistency between API definitions and their middleware configurations. The change doesn't modify authentication, authorization, input validation, or any other security-critical components. ## Summary
Tip: Mention me again using |
Analysis of PR #7261: [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCHThis PR addresses an important consistency issue between the Gateway CE and Dashboard when handling OAS API updates via PATCH operations. Problem IdentifiedWhen updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API, the Tyk vendor extension (x-tyk-api-gateway) wasn't properly updated to remove operations that were no longer present in the API definition. This resulted in:
Solution ImplementedThe PR adds a new func (s *OAS) removeObsoleteOperations(currentOperations []string) {
tykOperations := s.getTykOperations()
obsoleteOperations := make([]string, 0)
for id := range tykOperations {
if !slices.Contains(currentOperations, id) {
obsoleteOperations = append(obsoleteOperations, id)
}
}
for _, operationID := range obsoleteOperations {
delete(tykOperations, operationID)
}
} This function:
The currentOperations := make([]string, 0)
for path, pathItem := range s.Paths.Map() {
// ...
for _, method := range allowedMethods {
if operation := pathItem.GetOperation(method); operation != nil {
// ...
currentOperations = append(currentOperations, s.getOperationID(path, method))
// ...
}
}
}
s.removeObsoleteOperations(currentOperations) TestingThe PR adds a dedicated test for the func TestOAS_RemoveObsoleteOperations(t *testing.T) {
t.Run("should remove obsolete operations", func(t *testing.T) {
var s OAS
s.SetTykExtension(&XTykAPIGateway{
Middleware: &Middleware{
Operations: Operations{
"op1": &Operation{},
"op2": &Operation{},
"op3": &Operation{},
},
},
})
s.removeObsoleteOperations([]string{"op1", "op3"})
operations := s.getTykOperations()
assert.Len(t, operations, 2)
assert.Contains(t, operations, "op1")
assert.Contains(t, operations, "op3")
assert.NotContains(t, operations, "op2")
})
} It also adds a test case in ImpactThis fix ensures consistent behavior between Gateway CE and Dashboard when handling OAS API updates via PATCH operations. It maintains the integrity of API definitions by properly cleaning up obsolete operations in the Tyk extension, preventing potential issues with references to non-existent operations. Tip: Mention me again using |
Analysis of PR #7261: Fix for OAS PATCH Operation Middleware SyncThis PR addresses an important issue where updating an API with the PATCH operation via Gateway API doesn't properly update the Tyk vendor extension (x-tyk-api-gateway), resulting in out-of-sync or invalid API definitions. The ProblemWhen using PATCH to update an OAS API, operations that were removed from the API definition would still remain in the Tyk extension (x-tyk-api-gateway). This created inconsistencies between:
This inconsistency could lead to:
The SolutionThe PR introduces a new function
func (s *OAS) removeObsoleteOperations(currentOperations []string) {
tykOperations := s.getTykOperations()
obsoleteOperations := make([]string, 0)
for id := range tykOperations {
if !slices.Contains(currentOperations, id) {
obsoleteOperations = append(obsoleteOperations, id)
}
}
for _, operationID := range obsoleteOperations {
delete(tykOperations, operationID)
}
} The implementation is efficient and safe:
TestingA test case was added to verify that obsolete operations are properly removed:
This fix ensures consistent behavior between Gateway CE and Dashboard when handling OAS API updates via PATCH operations, maintaining the integrity of API definitions. Tip: Mention me again using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…-from-dashboard-for-middleware-and-patch
🛡️ Security Snapshot
## Security Impact AnalysisThe PR adds a ## Identified VulnerabilitiesNo vulnerabilities were identified in this change. The implementation:
## Security RecommendationsThe implementation is secure as-is. The only minor consideration would be to ensure that the ## OWASP ComplianceThis change doesn't impact any OWASP Top 10 categories directly. It's a maintenance function that ensures data consistency between API definitions and their middleware configurations. The change doesn't modify authentication, authorization, input validation, or any other security-critical components. ## SummaryNo security issues identified – change LGTM. Tip: Mention me again using |
📦 Impact Review Snapshot| Effort | Downstream Updates | Compatibility | Docs | TL;DR | ## Impact AssessmentThis PR addresses an important issue where PATCH operations on OAS APIs via Gateway API don't properly update the Tyk vendor extension (x-tyk-api-gateway), resulting in out-of-sync or invalid API definitions. The fix adds a The implementation is clean and efficient, first collecting all current operations during middleware import, then identifying and removing any operations in the Tyk extension that aren't in the current set. This ensures that when API paths are removed or modified via PATCH, the corresponding operations in the Tyk extension are properly cleaned up. ## Required UpdatesNo immediate updates are required in downstream repositories as this is a bug fix that doesn't change any schemas or interfaces. However, repositories that interact with both Gateway and Dashboard should be aware of the improved consistency:
## Compatibility ConcernsThis change has no backward compatibility issues. It's a bug fix that ensures the Gateway properly updates the Tyk vendor extension during PATCH operations, which aligns with expected behavior. The fix ensures that obsolete operations are properly removed from the Tyk extension, which was already the expected behavior but wasn't working correctly. The implementation uses standard Go library functions ( ## Summary & Recommendations
Tip: Mention me again using |
PR Analysis: Fix for OAS PATCH Operation Middleware SyncProblem OverviewThis PR addresses an important issue where updating an API with the PATCH operation via Gateway API doesn't properly update the Tyk vendor extension (x-tyk-api-gateway), resulting in out-of-sync or invalid API definitions. When using PATCH to update an OAS API, operations that were removed from the API definition would still remain in the Tyk extension (x-tyk-api-gateway). This created inconsistencies between:
Technical ContextThe PATCH operation is handled by the
The issue occurred because during this process, the Solution ImplementationThe PR introduces a new function
func (s *OAS) removeObsoleteOperations(currentOperations []string) {
tykOperations := s.getTykOperations()
obsoleteOperations := make([]string, 0)
for id := range tykOperations {
if !slices.Contains(currentOperations, id) {
obsoleteOperations = append(obsoleteOperations, id)
}
}
for _, operationID := range obsoleteOperations {
delete(tykOperations, operationID)
}
} The
func (s *OAS) importMiddlewares(overRideValues TykExtensionConfigParams) {
// ...
currentOperations := make([]string, 0)
for path, pathItem := range s.Paths.Map() {
// ...
for _, method := range allowedMethods {
if operation := pathItem.GetOperation(method); operation != nil {
// ...
currentOperations = append(currentOperations, s.getOperationID(path, method))
// ...
}
}
}
s.removeObsoleteOperations(currentOperations)
// ...
} TestingThe PR includes a test case that verifies the functionality:
ImpactThis fix ensures consistent behavior between Gateway CE and Dashboard when handling OAS API updates via PATCH operations, maintaining the integrity of API definitions and preventing potential issues with references to non-existent operations. The change improves the reliability of the API management process by ensuring that the Tyk extension accurately reflects the current state of the API definition, which is critical for proper request processing and middleware application. The implementation is efficient and safe:
Tip: Mention me again using |
🚀 Performance Snapshot
## Performance Impact AnalysisThe PR adds a new The implementation uses ## Critical AreasThe changes affect the API definition update path, specifically when using PATCH operations on OAS APIs. This is not in the critical request handling path, as it only impacts API management operations, not runtime request processing. The operation cleanup happens during API updates, which are infrequent administrative actions. The implementation is efficient for the expected scale of operations in a typical API definition (usually tens of operations, not thousands), making the linear search acceptable. ## Optimization RecommendationsThe current implementation is appropriate for the expected scale. If future APIs contain hundreds of operations, consider:
However, these optimizations are likely unnecessary for typical API definitions with a modest number of operations. ## Summary
Tip: Mention me again using |
…-from-dashboard-for-middleware-and-patch
🛡️ Security Snapshot
## Security Impact AnalysisThe PR adds a ## Identified VulnerabilitiesNo vulnerabilities were identified in this change. The implementation:
## Security RecommendationsThe implementation is secure as-is. The only minor consideration would be to ensure that the ## OWASP ComplianceThis change doesn't impact any OWASP Top 10 categories directly. It's a maintenance function that ensures data consistency between API definitions and their middleware configurations. The change doesn't modify authentication, authorization, input validation, or any other security-critical components. ## SummaryNo security issues identified – change LGTM. Tip: Mention me again using |
📦 Impact Review Snapshot
## Impact AssessmentThis PR addresses an issue where PATCH operations on OAS APIs via the Gateway API don't properly update the Tyk vendor extension (x-tyk-api-gateway), causing out-of-sync or invalid API definitions. The fix adds a The implementation is clean and efficient, first collecting all current operations during middleware import, then identifying and removing any operations in the Tyk extension that aren't in the current set. This ensures that when API paths are removed or modified via PATCH, the corresponding operations in the Tyk extension are properly cleaned up. ## Required UpdatesNo immediate updates are required in downstream repositories as this is a bug fix that doesn't change any schemas or interfaces. However, repositories that interact with both Gateway and Dashboard should be aware of the improved consistency:
## Compatibility ConcernsThis change has no backward compatibility issues. It's a bug fix that ensures the Gateway properly updates the Tyk vendor extension during PATCH operations, which aligns with expected behavior. The fix ensures that obsolete operations are properly removed from the Tyk extension, which was already the expected behavior but wasn't working correctly. The implementation uses standard Go library functions ( ## Summary & Recommendations
Tip: Mention me again using |
🚀 Performance Snapshot
## Performance Impact AnalysisThe PR adds a new The implementation uses ## Critical AreasThe changes affect the API definition update path, specifically when using PATCH operations on OAS APIs. This is not in the critical request handling path, as it only impacts API management operations, not runtime request processing. The operation cleanup happens during API updates, which are infrequent administrative actions. The implementation is efficient for the expected scale of operations in a typical API definition (usually tens of operations, not thousands), making the linear search acceptable. ## Optimization RecommendationsThe current implementation is appropriate for the expected scale. If future APIs contain hundreds of operations, consider:
However, these optimizations are likely unnecessary for typical API definitions with a modest number of operations. ## Summary
Tip: Mention me again using |
🚦 Connectivity Review Snapshot
## Connectivity Assessment
## Test Coverage Validation
## Security & Performance Impact
## Summary & Recommendations
Tip: Mention me again using |
…-from-dashboard-for-middleware-and-patch
🛡️ Security Snapshot
## Security Impact AnalysisThe PR adds a ## Identified VulnerabilitiesNo vulnerabilities were identified in this change. The implementation:
## Security RecommendationsThe implementation is secure as-is. The only minor consideration would be to ensure that the ## OWASP ComplianceThis change doesn't impact any OWASP Top 10 categories directly. It's a maintenance function that ensures data consistency between API definitions and their middleware configurations. The change doesn't modify authentication, authorization, input validation, or any other security-critical components. ## SummaryNo security issues identified – change LGTM. Tip: Mention me again using |
🚀 Performance Snapshot
## Performance Impact AnalysisThe PR adds a new The implementation uses ## Critical AreasThe changes affect the API definition update path, specifically when using PATCH operations on OAS APIs. This is not in the critical request handling path, as it only impacts API management operations, not runtime request processing. The operation cleanup happens during API updates, which are infrequent administrative actions. The implementation is efficient for the expected scale of operations in a typical API definition (usually tens of operations, not thousands), making the linear search acceptable. ## Optimization RecommendationsThe current implementation is appropriate for the expected scale. If future APIs contain hundreds of operations, consider:
However, these optimizations are likely unnecessary for typical API definitions with a modest number of operations. ## Summary
Tip: Mention me again using |
Analysis of PR #7261: [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCHProblem OverviewThis PR addresses an issue where updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API doesn't properly update the Tyk vendor extension (x-tyk-api-gateway), resulting in out-of-sync or invalid API definitions. When using PATCH to update an OAS API, operations that were removed from the API definition would still remain in the Tyk extension (x-tyk-api-gateway). This created inconsistencies between:
This inconsistency led to:
Technical ContextThe PATCH operation is handled by the
The issue occurred because during this process, the Solution ImplementationThe PR introduces a new function func (s *OAS) removeObsoleteOperations(currentOperations []string) {
tykOperations := s.getTykOperations()
obsoleteOperations := make([]string, 0)
for id := range tykOperations {
if !slices.Contains(currentOperations, id) {
obsoleteOperations = append(obsoleteOperations, id)
}
}
for _, operationID := range obsoleteOperations {
delete(tykOperations, operationID)
}
} The func (s *OAS) importMiddlewares(overRideValues TykExtensionConfigParams) {
// ...
currentOperations := make([]string, 0)
for path, pathItem := range s.Paths.Map() {
// ...
for _, method := range allowedMethods {
if operation := pathItem.GetOperation(method); operation != nil {
// ...
currentOperations = append(currentOperations, s.getOperationID(path, method))
// ...
}
}
}
s.removeObsoleteOperations(currentOperations)
// ...
} Implementation DetailsThe implementation follows a two-phase approach:
This approach avoids modifying the map during iteration and uses The fix is triggered during the PATCH operation when if tykExtensionConfigParams != nil {
err = oasObjToPatch.BuildDefaultTykExtension(*tykExtensionConfigParams, false)
if err != nil {
doJSONWrite(w, http.StatusBadRequest, apiError(err.Error()))
return
}
} TestingA test was added to verify the functionality: t.Run("operations not present in new oas paths definition should be removed", func(t *testing.T) {
fakeOperationName := "fakeOperation"
fakeOperation := &Operation{
MockResponse: &MockResponse{
Enabled: true,
},
}
oasDef := getOASDef(true, true)
// Add a fake operation to the Tyk extension
extension := &XTykAPIGateway{
Middleware: &Middleware{
Operations: map[string]*Operation{fakeOperationName: fakeOperation},
},
}
oasDef.SetTykExtension(extension)
// Verify the fake operation exists
assert.Greater(t, len(oasDef.getTykOperations()), 0)
// Call BuildDefaultTykExtension which should remove the fake operation
expectedOperations := getExpectedOperations(true, true, middlewareMockResponse)
err := oasDef.BuildDefaultTykExtension(tykExtensionConfigParams, true)
// Verify the fake operation was removed
assert.NoError(t, err)
assert.Equal(t, expectedOperations, oasDef.getTykOperations())
}) Impact and BenefitsThis fix ensures:
The implementation is efficient and safe, building a list of obsolete operations first before removing them to avoid modifying the map during iteration. The fix maintains backward compatibility and doesn't change any public interfaces or schemas. Tip: Mention me again using |
📦 Impact Review Snapshot
## Impact AssessmentThis PR addresses an issue where PATCH operations on OAS APIs via the Gateway API don't properly update the Tyk vendor extension (x-tyk-api-gateway), causing out-of-sync or invalid API definitions. The fix adds a The implementation is clean and efficient, first collecting all current operations during middleware import, then identifying and removing any operations in the Tyk extension that aren't in the current set. This ensures that when API paths are removed or modified via PATCH, the corresponding operations in the Tyk extension are properly cleaned up. ## Required UpdatesNo immediate updates are required in downstream repositories as this is a bug fix that doesn't change any schemas or interfaces. However, repositories that interact with both Gateway and Dashboard should be aware of the improved consistency:
## Compatibility ConcernsThis change has no backward compatibility issues. It's a bug fix that ensures the Gateway properly updates the Tyk vendor extension during PATCH operations, which aligns with expected behavior. The fix ensures that obsolete operations are properly removed from the Tyk extension, which was already the expected behavior but wasn't working correctly. The implementation uses standard Go library functions ( ## Summary & Recommendations
Tip: Mention me again using |
|
/release to release-5.8 |
Working on it! Note that it can take a few minutes. |
…dleware and PATCH (#7261) <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-7524" title="TT-7524" target="_blank">TT-7524</a></summary> <br /> <table> <tr> <th>Summary</th> <td>[OAS] Gateway CE behaves differently from Dashboard for middleware and PATCH</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 --> Updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API does not trigger the Tyk vendor extension (x-tyk-api-gateway) update, which results in the API description being out of sync or invalid. <!-- 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. --> <!-- Why is this change required? What problem does it solve? --> <!-- 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. --> <!-- 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) <!-- 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 ___ Bug fix, Tests ___ - Fix removal of obsolete operations in Tyk extension during OAS PATCH. - Add test to ensure outdated operations are deleted. - Enhance middleware import logic for operation cleanup. - Improve consistency between Gateway and Dashboard OAS handling. ___ ```mermaid flowchart LR PATCH_OAS["PATCH OAS API"] -- "Triggers" --> importMiddlewares["importMiddlewares updates operations"] importMiddlewares -- "Collects current ops" --> removeObsolete["removeObsoleteOperations removes outdated ops"] removeObsolete -- "Cleans up" --> TykExtension["Tyk Extension up-to-date"] default_test["Add test for obsolete ops removal"] -- "Verifies" --> removeObsolete ``` <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>default.go</strong><dd><code>Remove obsolete operations from Tyk extension during import</code></dd></summary> <hr> apidef/oas/default.go <ul><li>Track current operations during middleware import.<br> <li> Add <code>removeObsoleteOperations</code> to delete outdated operations.<br> <li> Call cleanup after updating operations.<br> <li> Use <code>slices.Contains</code> for efficient operation checks.</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7261/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+21/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>default_test.go</strong><dd><code>Test removal of obsolete operations from Tyk extension</code> </dd></summary> <hr> apidef/oas/default_test.go <ul><li>Add test to verify removal of outdated operations.<br> <li> Ensure Tyk extension matches expected operations after update.</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7261/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+28/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> </details> ___ (cherry picked from commit dbabb5f)
@MaciekMis Created merge PRs |
…y from Dashboard for middleware and PATCH (#7261) (#7292) ### **User description** [TT-7524] [OAS] Gateway CE behaves differently from Dashboard for middleware and PATCH (#7261) ### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-7524" title="TT-7524" target="_blank">TT-7524</a></summary> <br /> <table> <tr> <th>Summary</th> <td>[OAS] Gateway CE behaves differently from Dashboard for middleware and PATCH</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 Updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API does not trigger the Tyk vendor extension (x-tyk-api-gateway) update, which results in the API description being out of sync or invalid. ## 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, Tests ___ ### **Description** Remove obsolete Tyk operations on OAS PATCH Track current operations during import Add test verifying obsolete cleanup Keep Gateway and Dashboard behavior consistent ___ ### Diagram Walkthrough ```mermaid flowchart LR OAS["OAS Paths/Operations"] -- "importMiddlewares" --> Collect["Collect current operation IDs"] Collect -- "compare" --> Cleanup["removeObsoleteOperations deletes stale ops"] Cleanup -- "result" --> XTyk["x-tyk-api-gateway middleware up-to-date"] Test["Unit test"] -- "asserts cleanup" --> Cleanup ``` <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>default.go</strong><dd><code>Remove obsolete operations during middleware import</code> </dd></summary> <hr> apidef/oas/default.go <ul><li>Track current operation IDs during import.<br> <li> Remove obsolete operations via new helper.<br> <li> Use slices.Contains for membership checks.<br> <li> Invoke cleanup after per-operation import.</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7292/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+21/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>default_test.go</strong><dd><code>Test cleanup of obsolete Tyk operations</code> </dd></summary> <hr> apidef/oas/default_test.go <ul><li>Add test ensuring obsolete operations are removed.<br> <li> Validate Tyk extension matches expected operations.</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7292/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+28/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> </details> ___ [TT-7524]: https://tyktech.atlassian.net/browse/TT-7524?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Maciej Miś <[email protected]>
User description
TT-7524
Description
Updating an API with the PATCH /tyk/apis/oas/{apiId} command via Gateway API does not trigger the Tyk vendor extension (x-tyk-api-gateway) update, which results in the API description being out of sync or invalid.
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Fix removal of obsolete operations in Tyk extension during OAS PATCH.
Add test to ensure outdated operations are deleted.
Enhance middleware import logic for operation cleanup.
Improve consistency between Gateway and Dashboard OAS handling.
Diagram Walkthrough
File Walkthrough
default.go
Remove obsolete operations from Tyk extension during import
apidef/oas/default.go
removeObsoleteOperations
to delete outdated operations.slices.Contains
for efficient operation checks.default_test.go
Test removal of obsolete operations from Tyk extension
apidef/oas/default_test.go