-
Notifications
You must be signed in to change notification settings - Fork 72
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
Bad ambiguous URI resolution #1567
Comments
We must have missed the fact that smithy-lang/smithy#1029 has been resolved. We'll have to tackle this for sure... |
Had a quick read of the rules, at first sight it looks like we'll just have to sort the routes before combining them. This code in private val httpEndpointHandlers: List[HttpEndpointHandler] =
service.endpoints.toList
.map { makeHttpEndpointHandler(_) }
.collect { case Right(endpointWrapper) => endpointWrapper }
private val perMethodEndpoint: Map[HttpMethod, List[HttpEndpointHandler]] =
httpEndpointHandlers.groupBy(_.httpEndpoint.method) (there are two occurrences of it) should be adjusted so that the endpoints are sorted according to the specificity algorithm. This can be done after grouping, so that we sort smaller lists. so, something like private val perMethodEndpoint: Map[HttpMethod, List[HttpEndpointHandler]] =
httpEndpointHandlers.groupBy(_.httpEndpoint.method)
.map { case (method, es) => (method, es.sortBy(specificity)) } might do it. We'll need some tests for the whole thing, and I'd also like to see that code deduplicated (together with |
Yup sorting seems like it'll be good enough. |
Note: I'm struggling to make the project compile. I'm currently unable to navigate correctly in the code. TBH, I'm not used to nix, flakes, or that kind of development environment. I will need some time to set up my environment for trying to handle this. I'm using latest version of IntelliJ Idea (2024.1.4) with latest scala plugin (2024.1.25). |
FYI you don't need Nix/flakes for local development, it's mostly useful here if you want to have a consistent experience with the website (which shouldn't be necessary here) :) IntelliJ is known not to handle more complex types very well, we mostly use Metals in VS Code here. Maybe some of these hints will help? https://hmemcpy.com/2021/09/bsp-and-intellij/ Also, have you tried the nightlies? |
Forgot about this one for a bit. @Isammoc have you made any progress? |
Hi @kubukoz,
nightlies of which project? But, yeah the holidays passed by, and I forgot too. Sorry about that |
From smithy 2.0 documentation, the server should route ambiguous URI in a specific order.
My current extract:
Reproduction:
Main.scala
)sbt run
Current behavior
The method for broader endpoint is run:
Expected behavior
More specific method is preferred:
Notes
If this is from the same service, the order of operations seems to affect the affect the order of matching.
For different services, the order will be directly from the scala code that calls.
How can I help?
The text was updated successfully, but these errors were encountered: