-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Empty placeholders: Failed to match Route configuration for upstream path #748
Comments
I always thought that it was designed to work this way, let's see if we can get some clarification... |
New day has come and the new ideas with it. :) Well. I thought about it and it is not as simple as I wrote in the first post. The problem is, that empty placeholder is not allowed in upstream URLs - special exception is catch all upstream So for example, I would not allow empty placeholder in this configuration.
Because the most probably I do not want it to catch upstream URL So I would formulate my proposal this way. If the same placeholder is at the end of both upstream and downstream path after the slash, it should work with empty value. Furthermore, when the placeholder is empty, this upstream route should match URL without the trailing slash. To clarify this - for me, it is the same as catch all route Simple catch all URL
Will reroute:
Multiple placeholders
Will reroute:
Empty value for Placeholder in the middle of the path
Or
Empty value for Different placeholders at the ends
Empty value is not allowed for any of the placeholders. The placeholder at the end must be the same. ConclusionSo what I am thinking about is like extending current behavior of catch all URL |
#737 changes the way the matching templates are created and used, I did not change this behavior as it appeared to be by design. A few days ago I tried having the catch all catch 0 or more if it's the last segment of the pattern, but this caused some acceptance tests to fail which were explicitly verifying that did not happen. As such, I believe this is an intended behavior, but I think as part of #737 we may have some workarounds, particularly, using a grouping match instead of a placeholder. I will discuss with the team. |
Hi Team, Request Url:- |
Hi. |
@raman-m Can I work on this issue ? |
@AlyHKafoury Yes, you can! |
@AlyHKafoury First of all, please verify (validate, repro) this bug. |
@raman-m I am adding a unit test for it first and then will fix it, after I reproduce and create a unit test |
@raman-m I can verify the error exists and I have a unit-test for it here https://github.com/ThreeMammals/Ocelot/pull/1911/files |
…ll placeholders at the end of template (#1911) * Update RoutingTests.cs * Fix end of line empty placeholder * Fix unit tests * Fix PR Comments * Update src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs Co-authored-by: Raman Maksimchuk <[email protected]> * Update src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs Co-authored-by: Raman Maksimchuk <[email protected]> * Update test/Ocelot.AcceptanceTests/RoutingTests.cs Co-authored-by: Raman Maksimchuk <[email protected]> * Update test/Ocelot.AcceptanceTests/RoutingTests.cs Co-authored-by: Raman Maksimchuk <[email protected]> * Update test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs Co-authored-by: Raman Maksimchuk <[email protected]> * compact the tests constant name * remove constant * Update RoutingTests.cs * Update RoutingTests.cs * Update RoutingTests.cs * Update UrlPathPlaceholderNameAndValueFinderTests.cs * Use range operator * Use expression body for method * Update src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddleware.cs Co-authored-by: Raman Maksimchuk <[email protected]> * Update DownstreamUrlCreatorMiddleware.cs * add extra unit tests * Update RoutingTests.cs * Clean code * Update UrlPathPlaceholderNameAndValueFinderTests.cs * Update DownstreamUrlCreatorMiddlewareTests.cs * Update DownstreamUrlCreatorMiddlewareTests.cs * Fix broken dsPath * Review tests. Add query string scenarios * Fix unit test and fix +1 issue * Add final routing tests for Catch-All query string cases * Fixed added unit tests * Test traits * Update docs of Routing feature --------- Co-authored-by: Raman Maksimchuk <[email protected]>
Expected Behavior
Match upstream path with empty placeholder and map it correctly to downstream.
Actual Behavior / Motivation for New Feature
Upstream path with placeholder is not working as expected when placeholder is empty. It fails with error:
UnableToFindDownstreamRouteError Message: Failed to match ReRoute configuration for upstream path: /test
Steps to Reproduce the Problem
This special catch all configuration of ReRoute works as expected
It maps URLs this way:
Now this mapping (downstream is the same):
It works correctly when
{url}
is specified:/test/123 → /api/invoices/123
But it fails, when
{url}
is empty. I would expect upstream URL/test/
to reroute to downstream URL/api/invoices/
. The error is:As a special case of this, I would also expect routing to ignore trailing slash, because from WEB/API wiew, usually the address with the slash at the end is the same as without it. So upstream URL
/test
would map to downstream URL/api/invoices
. Maybe this is not exact from the computers point of view, but for me it makes sense from human point of view of configuration. It does not work this way even if the routing is configured without the slashes:It correctly maps non epmty
{url}
which means, it works with the slash at the end, because the slash is the value of the{url}
. But still not without it:To make work everything what I want, I need three reroutes (or at least two, if the first one will be without slashes):
Specifications
The text was updated successfully, but these errors were encountered: