-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Catch All functionality priority routing partially broken #2134
Comments
This seems to also happen with multiple levels of catch all Ocelot: "Routes": [
{
"UpstreamHttpMethod": [ "Get" ],
"UpstreamPathTemplate": "/test/{url}/{url2}",
"DownstreamPathTemplate": "/generic/{url}/{url2}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 8000
}
]
},
{
"UpstreamHttpMethod": [ "Get" ],
"UpstreamPathTemplate": "/test/{url}",
"DownstreamPathTemplate": "/specific/{url}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 8000
}
]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5000"
} Only |
Hello Sims!
Actually, the functionality was "broken"/changed specifically in version 23.0.0 as seen in the commit f4803c2.
Understood. However, it's important to note that the two screenshots pertain to distinct features. Additional details follow.
Correct! It is connected to PR #1911. While #748 was initially closed with the bug fix in #1911, it turns out that #748 contains new functionality requirements, making #1911 a feature PR rather than a simple bug fix. |
The screenshot and user scenario depicted precisely illustrate the Catch All Routing feature. It is operational and continues to function in version 23.3. Perfect! |
Hi @raman-m, I'm a little confused by your response. Is this a bug or am i not using the features of Ocelot correctly?
So is the catch-all feature only supposed to be used for the root path? Can you link me the documentation for a similar feature for a catch-all on subpaths? Also, am i correct to think that the input url that matches the upstream template more closely should be taken, rather than a priority from first to last? (Otherwise you'd be unable to create more advanced routing definitions) Another question, can i disable the feature that's causing this as a temporary workaround? |
The "Screenshot 2" user scenario pertains to the Empty Placeholders feature. Both upstream templates
Subsequently, the foreach loop iterates over all the applicable routes and generates a new list of downstream routes:
However, since the Priority feature is not employed, the first route in the list is selected by default. Additionally, it can be said that the Actual behavior is derived from the Empty Placeholders feature. Conversely, the Expected behavior is a result of the Priority feature. To achieve the expected behavior, one must employ the Priority routing feature, which is specifically designed for scenarios with implicit or unclear route priorities. |
For #2134 (comment), it's impossible to use priority to solve this. The first match will always swallow the entire url. |
I understand your interest in software testing, but what is the purpose of such detailed analysis? Both
Indeed, the URL matches the second route template because it does not have two subpaths required to match the first route. Bingo!
Indeed, the URLs All behavior is correct! There are no issues. However, there seems to be a lack of clarity regarding the Routing feature, which warrants a second reading by you. Experimenting with subpaths while disregarding the existing, ready-to-use features is nonsensical. Such experiments often lead to confusion and are prone to failure. It's advisable to fully utilize the power of the already implemented Routing features before attempting to develop more customized solutions on top of the existing functionality. |
@suchmememanyskill commented on Aug 2, 2024
I haven't had the time to verify the accuracy of the statement, but it appears everything is detailed in my #2134 (comment). "Routes": [
{
"UpstreamPathTemplate": "/generic/{url}/{url2}",
"DownstreamPathTemplate": "/generic/{url}/{url2}",
},
{
"UpstreamPathTemplate": "/specific/{url}",
"DownstreamPathTemplate": "/specific/{url}",
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5000"
} This solution is elegant and avoids the need for debates with the product owner. 😉 |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Bug
Since release v23, the catch all functionality seems to be broken on subpaths. Absolute routes no longer match over catch-all ones.
Screenshot 1 works as intended, Screenshot 2 does not.
This seems to be related to this PR: #1911
Expected behaviour (Screenshot 1):
Actual behaviour (Screenshot 1):
Screenshot 1:
Expected behaviour (Screenshot 2):
Actual behaviour (Screenshot 2):
Screenshot 2:
Specifications
The text was updated successfully, but these errors were encountered: