Closed buger closed 1 week ago
Here are some key observations to aid the review process:
**๐ซ Ticket compliance analysis ๐ถ** **[6705](https://github.com/TykTechnologies/tyk/issues/6705) - Partially compliant** Fully compliant requirements: - Fix domain matching edge case related to substring listen paths. - Update the sorting function for listen paths. - Address compatibility issues on macOS with Apple Silicon for httpbin service. Not compliant requirements: - Add unit tests. |
โฑ๏ธ Estimated effort to review: 2 ๐ต๐ตโชโชโช |
๐งช No relevant tests |
๐ No security concerns identified |
โก Recommended focus areas for review Sorting Logic The new sorting logic for API specs should be thoroughly tested to ensure it handles edge cases correctly, especially when domains are empty. |
API Changes
no api changes detected
Explore these optional code suggestions:
Category | Suggestion | Score |
Possible issue |
Improve the sorting logic to handle cases where both domains are empty___ **Ensure that the sorting logic insortSpecsByListenPath correctly handles cases where Domain is empty for both compared elements. Currently, it only checks if they are different, which might lead to inconsistent sorting when both are empty.** [gateway/api_loader.go [934-937]](https://github.com/TykTechnologies/tyk/pull/6723/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68R934-R937) ```diff +if specs[i].Domain == "" && specs[j].Domain == "" { + return len(specs[i].Proxy.ListenPath) > len(specs[j].Proxy.ListenPath) +} if (specs[i].Domain == "") != (specs[j].Domain == "") { return specs[i].Domain != "" } return len(specs[i].Proxy.ListenPath) > len(specs[j].Proxy.ListenPath) ``` Suggestion importance[1-10]: 7Why: The suggestion correctly identifies a potential issue in the sorting logic where both domains are empty, which could lead to inconsistent sorting results. The improved code explicitly handles this scenario, ensuring more predictable and stable sorting behavior. | 7 |
User description
TT-13507 Fix for custom domains with substring listen path (#6705)
User description
Actual fix for domain matching edge case related to substring listen paths. Fixed the sorting function for the listen paths and added some unit tests.
Extra: httpbin service not working on macos with apple silicon; now it does
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Bug fix, Configuration changes
Description
linux/amd64
, addressing compatibility issues on macOS with Apple Silicon.Changes walkthrough ๐
api_loader.go
Fix domain sorting logic in API loader
gateway/api_loader.go
httpbin.yml
Specify platform for httpbin service in Docker configuration
docker/services/httpbin.yml - Added platform specification for httpbin service.
PR Type
Bug fix, Configuration changes, Tests
Description
api_loader.go
to ensure correct domain matching by prioritizing non-empty domains and sorting by listen path length.linux/amd64
) for the httpbin service in the Docker configuration to address compatibility issues on macOS with Apple Silicon.api_loader_test.go
to verify the correct order of API specs by listen path.Changes walkthrough ๐
api_loader.go
Refactor domain sorting logic in API loader
gateway/api_loader.go
httpbin.yml
Specify platform for httpbin service in Docker
docker/services/httpbin.yml
configuration.
api_loader_test.go
Add unit tests for domain sorting logic
gateway/api_loader_test.go
api_loader_test.go
...
gateway/api_loader_test.go ...