-
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
Regression at DownstreamUrlCreatorMiddleware #2002
Comments
Same. |
Hi @bbenameur ! This is not "regression"! This is new feature and bug fix of PR #1182 (commit ae43f32) My recommendation is rolling back to version 21.0.0 until you understand how to use new feature. Let me to explain...
Your route definition is invalid! I wonder that your app started at all. You should have some warnings and errors in logs. Mistake 1: Double curly bracesWe must use single "UpstreamPathTemplate": "/WeatherForecast/{roleId}/groups?something=9874565",
"DownstreamPathTemplate": "/account/{username}/groups/{groupName}/roles?roleId={roleId}", Maybe you used double Mistake 2: Redundant placeholders or absent onesBoth templates must have the same placeholders. Otherwise Ocelot validator generates at least warnings in logs! "UpstreamPathTemplate": "/WeatherForecast/{roleId}/groups?something=9874565",
"DownstreamPathTemplate": "/account/username/groups/groupName/roles?roleId={roleId}", If you have to have both Mistake 3: Ignoring Catch All approachAs a team, we recommend always to define Catch All routes. But more concrete URLs need to be defined for transformations like your user case of Placeholders for query string. "UpstreamPathTemplate": "/WeatherForecast/{roleId}/groups?{everything}",
"DownstreamPathTemplate": "/account/username/groups/groupName/roles?roleId={roleId}&{everything}", Mistake 4: Ignoring Restrictions on useQuery string manipulation has Restrictions on use when defining template with query strings.
In your case the problem with "UpstreamPathTemplate": "/WeatherForecast/{role}/groups?{everything}",
"DownstreamPathTemplate": "/account/username/groups/groupName/roles?roleId={role}&{everything}", So, your {role} placeholder will be mapped as Now let's improve your templates. Originally logically you wanted to define such generic route: "UpstreamPathTemplate": "/WeatherForecast/{role}/groups?{everything}",
"DownstreamPathTemplate": "/account/{userName}/groups/{groupName}/roles?roleId={role}&{everything}", But as I said, Solution 1
"UpstreamPathTemplate": "/WeatherForecast/{role}/groups?userId={user}&groupId={group}&{everything}",
"DownstreamPathTemplate": "/account/{user}/groups/{group}/roles?roleId={role}&{everything}", We believe this is the most correct scenario and it gives exactly what you want. Solution 2
"UpstreamPathTemplate": "/WeatherForecast/{role}/groups?{everything}",
"DownstreamPathTemplate": "/account/user1/groups/group1/roles?roleId={role}&{everything}", But this solution requires probably to make a lot of routes. So, that's why to develop and use Solution 1. Hope it helps! |
It is hard to give an advice if no routes definitions, only some URLs! |
Hello @raman-m "UpstreamPathTemplate": "/WeatherForecast/{role}/groups?{everything}",
"DownstreamPathTemplate": "/account/{userName}/groups/{groupName}/roles?roleId={role}&{everything}", /WeatherForecast/ We have a very large BFF Ocelot and the developer will be able to easily identify the palceholder query string, no need to change. The code is the MR : #2003 work correclty with a little code , mabay is not a |
I've explained you above and provided you solutions how to keep the parameter in query not breaking behavior of downstream service. Yes, you have to review
I don't understand you! "No need to change"... Well... Before you realized that new versions have new behavior you had to read Release Notes for version 22.0. After 4 months you came back and you want change and improve something. It is a little bit late!
I don't see any features. |
I will double check that we had a regression... |
Hi raman I understand that the fix is pending for this issue due to missing and outdated test cases. Do you believe this issue needs to be there in 23.3 as it’s delaying other critical issues which already have been fixed from getting released? So can I request to please move this issue to next release 23.4/24.1 or 24.0 so that 23.3 can go through! If this is doable though as per the criticality of this issue. It’s just a request to reconsider! Thanks, |
…mUrlCreatorMiddleware` (#2003) * issues/2002 : Regression at DownstreamUrlCreatorMiddleware * issues/2002:: add some unit tests and acceptance test * issues/2002: fix test * Apply suggestions from code review Co-authored-by: Raynald Messié <[email protected]> * issues/2002: fix build * CS8936 Feature 'collection expressions' is not available in C# 10.0. Please use language version 12.0 or greater. * Code review by @ggnaegi #2003 (review) * Original version from develop * The fix by @bbenameur with improved version by @ggnaegi * Don't order parameters, add to the end * AAA pattern in unit tests * Double-check tests * Remove BDDfy * Inherit from `Steps` * DRY in acceptance tests * Tests for #2002 user scenario * Update docs --------- Co-authored-by: Raynald Messié <[email protected]> Co-authored-by: Raman Maksimchuk <[email protected]>
Expected Behavior
There is a regression since version 22.0.0 and even in version 23.0.0.
The correct behabior is :
Actual Behavior / Motivation for New Feature
But currently all query from Downstream path was removed
Steps to Reproduce the Problem
Make sure that you have a query from DownstreamPathTemplate and UpstreamPathTemplate
Specifications
The text was updated successfully, but these errors were encountered: