Change in routing behavior? #2040
Replies: 2 comments 2 replies
-
Hi @flmbray ! #1288 is not related to your case. PR #1288 fixed another problem.
Please show me what you have done. {
"UpstreamPathTemplate": "/v1.0/document/getItemStatus?{everything}",
},
{
"UpstreamPathTemplate": "/v1.0/document/getItemStatusHistory?{everything}",
} The current version of our documentation defines "Catch All Query String" templates, which is a unique feature designed to route all query strings for a static path. But your logs are:
I can't find any requests to the I'm unable to make a decision as your log appears incomplete. It could theoretically be an issue with the matching paths' priority for Catch All Query String templates.
It's unfortunate to hear that. It's important to respect your former colleagues' decisions. Why not consider hiring a developer to update your Ocelot to the latest version? If the old version was functioning well, what prompted you to begin upgrading your solution?
This is the expected behavior for the Catch All Query String feature when dealing with static paths. The confusion may arise from the assumption that paths can be dynamic.
I don't observe any bugs; rather, it appears to be a misconfiguration issue and a lack of documentation review. For breaking changes in major versions, we accept bug reports to open hotfix PRs and typically release the hotfix within one to two days. Hotfixes are usually released in 1-2 days. However, we are an open-source project, not a commercial one, and we do not have support engineers on our team. It seems it might be time for Ocelot to adopt some commercial aspects.
Please revert to the previous version to ensure the stability of your solution. You may also want to consider updating to version 23.2.2, which includes a hotfix.
{
"UpstreamPathTemplate": "/v1.0/document/getItemStatus?{everything}",
"DownstreamPathTemplate": "/v1.0/document/getItemStatus?{everything}"
},
{
"UpstreamPathTemplate": "/v1.0/document/getItemStatusHistory?{everything}",
"DownstreamPathTemplate": "/v1.0/document/getItemStatusHistory?{everything}"
} Defining dynamic routes with varying query strings while also having dynamic paths can be problematic. This approach is a definitional error; it would be more efficient to merge both routes into a single one, for example: {
"UpstreamPathTemplate": "/v1.0/document/{everything}",
"DownstreamPathTemplate": "/v1.0/document/{everything}"
}, The Catch All route definition includes all query strings and should address any issues with priority and path matching. Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
That is pretty much the point I'm trying to demonstrate. The API call comes in to Ocelot as
The first log is a bit confusing because it appears to be out of order (it incorrectly refers to
This would make sense to me if it was only picking up changes in the query string.... but this catch-all seems to be also picking up an overlap in the path - it's almost like it is treating I have been able to create a nice demonstration of this... I've attached a file: Ocelot.zip. This zip contains three files:
Once you extract the zip file, open the LinqPad script (it links Ocelot latest-version, currently 23.2.2, via Nuget so it might ask if you want to download it). Open the ocelot.json config and note that it defines two routes under
Note that Now run the Postman operation for And then for the final test, stop the Ocelot service, edit the ocelot.json file and swap the order of the two routes so that I can certainly understand that the order of routes in the config file can make a difference, but it doesn't make sense that So to conclude this, I ask you to please try my sample demonstration files to get a better understanding of what I think is wrong, and if you say again that you think it is operating as designed then I will work around the issue on my end. Thank you so much for your time and dedication to supporting the community! |
Beta Was this translation helpful? Give feedback.
-
Hi... somewhere between 19.0.1 and 23.1.0, it seems something changed regarding how routes get handled. Our configuration had the following PathTemplates like this, in this order (omitting all the other parameters for brevity):
Prior to the upgrade (i.e. when we were using 19.0.1) these routes worked as expected. Since the upgrade to 23.1.0, we have recently discovered that when clients call
getItemStatusHistory
, Ocelot is actually picking and executing the downstream forgetItemStatus
instead (note the corresponding requestId values):We were able to resolve this by swapping the order of the two routes in our configuration file, putting the route for
getItemStatusHistory
first. I don't see anything specifically about this in the release notes, although I saw a couple of pull request merges that might be the cause, this one in particular from 20.0.0. I'm also not completely sure we are using the templates correctly - this isn't my area of expertise and the people that originally implemented Ocelot in our project are no longer with us. However with my limited understanding, it seems that maybe Ocelot is somehow overlooking the?
and matching{everything}
in thegetItemStatus
route to the "History" portion in the url. Previously, it seems that the presence of the?
in thegetItemStatus
template prevented this, as I would expect.So I guess what I'm asking is:
{template}
capability? If so, please clarify.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions