-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Routes with parameters are not working in some cases #2188
Comments
@ambienthack thank you for reporting the issue, your analysis looks reasonable to me. Would you like to contribute the fix yourself? See https://loopback.io/doc/en/contrib/code-contrib.html to get started. @raymondfeng you are the author of the trie router, could you PTAL? |
I seem to have run into the same issue. These are my controller actions Action 1
Action 2
Current Behavior
Expected BehaviorController method should be invoked Other ObservationsEven after removing Action 2 and all other actions in the controller that matches the same route Action 1 is still not being invoked. |
would really appreciate if this could be resolved soon. |
@Joel-Raju Do you have both methods in the same controller class? |
BTW, do you know if |
Can you remove trailing @get('/restaurants', {
async find(
@param.query.object('filter', getFilterSchemaFor(Restaurant))
filter?: Filter,
): Promise<Restaurant[]> {
return await this.restaurantRepository.find(filter);
} |
@Joel-Raju Please verify #2355. Let us know whether the newly added test cover your case or not. |
@raymondfeng thanks for the quick follow-up
Yes.
It doesn't seem to hit route
When removing the trailing space, the
this covers my use case. |
I first have Even tried just with These are the request URLs this works this doesnt work |
@Joel-Raju Can you create a simple app that can reproduce your problem and share it with us on github? |
@raymondfeng forked and added a sample project that illustrates the issue https://github.com/Joel-Raju/loopback-next/tree/master/sandbox/test-app this route works this doesn't work |
Guess I didn't mention that I have a |
@Joel-Raju Thanks for the sample app. I was able to reproduce the problem and fix it in #2355. |
That's the root cause as you added |
oh okay. This will get resolved with #2355 ? |
Yes. Before it's landed, you can probably work around the issue by changing the path |
thanks 👍 |
Description / Steps to reproduce / Feature proposal
Create two routes like this
Make a request PATCH /users/5c1d78842566764efc8b9605
Current Behavior
If the error doesn't arise, try changing parameter names in path patterns, like this:
@patch('/users/{id}/meals/{mealId}')
@patch('/users/{userId}')
Expected Behavior
Controller method should be invoked
I believe there is a bug here
Should be
if (result && isNodeWithValue(result.node)) {
.When multiple children are found, if the first child checked is
@patch('/users/{userId}/meals/{id}')
, search() method assumes route is found & doesn't check other routes.The text was updated successfully, but these errors were encountered: