Skip to content
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

DuplicateRouteException when using two Controller uris #10957

Closed
johndevs opened this issue Jul 8, 2024 · 13 comments · Fixed by #11187
Closed

DuplicateRouteException when using two Controller uris #10957

johndevs opened this issue Jul 8, 2024 · 13 comments · Fixed by #11187
Labels
info: good first issue Good for newcomers type: bug Something isn't working

Comments

@johndevs
Copy link

johndevs commented Jul 8, 2024

Expected Behavior

When I create two end-points like this:

@Get(uris = { "/foo", "/bar" }
public String method1(){ ... }

@Get(uris = { "/one", "/two" }
public String method2(){ ... }

And call /foo then I expect method1() to be executed.

I would also expect if there is an error with duplicate routing that the error log would include the controller class and method names for easier debugging.

Actual Behaviour

Instead I get DuplicateRouteException thrown from the Router#findClosest(request) with the message:

More than 1 route matched the incoming request. The following routes matched /: GET - /, GET - /

From this message it is not clear which controller methods are conflicting nor is the error correct.

Apparently the Router only considers the uri parameter, not uris.

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.2.2

@graemerocher graemerocher added type: bug Something isn't working info: good first issue Good for newcomers labels Jul 8, 2024
@ersalazar
Copy link

Hello; can I work on this?

@yawkat
Copy link
Member

yawkat commented Jul 11, 2024

sure

@pragyamutluru
Copy link
Contributor

Hi @ersalazar , are you working on this?
I was also planning to start on it.

Should we throw a new exception (such as MultipleRouteException) which communicates a more succinct message?

@graemerocher
Copy link
Contributor

better error messages are always good

@ersalazar
Copy link

Hello @pragyamutluru, yes I'm working on it. I know its been a bit long but I ran into an issue where I couldnt run the project locally but that was fixed yesterday in this PR #10990

@ersalazar
Copy link

I'm trying to replicate the error in version 4.6.x but it seems to be fixed. When I try to go to version 4.2.x where this error was reported I get the same dependency error that was patched in 4.6.x with PR #10990 Can anyone help me with this?

@ersalazar
Copy link

@yawkat can you help me with this?

@yawkat
Copy link
Member

yawkat commented Jul 22, 2024

I think the easiest way would be to try reproducing this bug outside micronaut-core, where #10990 does not apply. That can help narrow down whether this issue existed in 4.2.x.

@pragyamutluru
Copy link
Contributor

I am also unable to reproduce the issue with 4.6.x and with 4.2.x.
@johndevs if you could please provide us with dependency list, that would be great!

@yawkat
Copy link
Member

yawkat commented Jul 24, 2024

Thanks for testing. I will close this issue for now. @johndevs please provide a test case.

@yawkat yawkat closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
@yawkat yawkat added the closed: cannot reproduce The issue cannot be reproduced label Jul 24, 2024
@johndevs
Copy link
Author

Thanks everyone for testing!

We did quite a big migration from 4.2.2 to 4.5.1 and now I cannot either reproduce this issue anymore. So something in some version in-between has fixed it for sure. Or it was some transient dependency that was updated in the process that was causing issues.

Anyway, sorry to bother you all with testing an old version; but great to see such an active team working on Micronaut! 🍻

@johndevs
Copy link
Author

@yawkat I have managed to reproduce the issue now on 4.5.1 as well.

Attached a minimal test-case. I would expect the test in the project to pass.

duplicate-uris-test-case.zip

@yawkat yawkat reopened this Sep 2, 2024
@yawkat yawkat removed the closed: cannot reproduce The issue cannot be reproduced label Sep 2, 2024
@yawkat
Copy link
Member

yawkat commented Sep 2, 2024

Thanks for the reproducer. I think it still uses the default value for uri even though you have an explicit uris parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info: good first issue Good for newcomers type: bug Something isn't working
Projects
None yet
5 participants