Skip to content

Multiple actions matched exception when updating from .NET 6 to .NET 7 using OData 7.x #943

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

Closed
xuzhg opened this issue Dec 19, 2022 · 4 comments

Comments

@xuzhg
Copy link

xuzhg commented Dec 19, 2022

Hi, Chris

I attached a sample (OData 7.x web application service) below. It works fine:

Run it and send request 'GET' http://localhost:5281/odata/Jobs

image

HOWEVER:

If I change the target framework to .net 7 as:

image

Do the same request: I will get the exception as:

fail: Microsoft.AspNetCore.Mvc.Routing.DefaultApiVersionRoutePolicy[1]
      Request matched multiple actions resulting in ambiguity. Matching actions: WebApplication1.Controllers.JobsController.Get(int, ODataQueryOptions<Job>, CancellationToken) (WebApplication1)
      WebApplication1.Controllers.JobsController.Get(ODataQueryOptions<Job>, CancellationToken) (WebApplication1)
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMN21VQJ7KI1", Request id "0HMN21VQJ7KI1:00000004": An unhandled exception was thrown by the application.
      Microsoft.AspNetCore.Mvc.Infrastructure.AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:

      WebApplication1.Controllers.JobsController.Get(int, ODataQueryOptions<Job>, CancellationToken) (WebApplication1)
      WebApplication1.Controllers.JobsController.Get(ODataQueryOptions<Job>, CancellationToken) (WebApplication1)
         at Microsoft.AspNetCore.Mvc.Routing.DefaultApiVersionRoutePolicy.OnMultipleMatches(RouteContext context, ActionSelectionResult selectionResult)
         at Microsoft.AspNetCore.Mvc.Routing.DefaultApiVersionRoutePolicy.Evaluate(RouteContext context, ActionSelectionResult selectionResult)
         at Microsoft.AspNetCore.Mvc.Versioning.ODataApiVersionActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList`1 candidates)
         at Microsoft.AspNet.OData.Extensions.ODataEndpointRouteValueTransformer.TransformAsync(HttpContext httpContext, RouteValueDictionary values)
         at Microsoft.AspNetCore.Mvc.Routing.DynamicControllerEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
         at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
         at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
         at Microsoft.WebTools.BrowserLink.Net.BrowserLinkMiddleware.ExecuteWithFilterAsync(IHttpSocketAdapter injectScriptSocket, String requestId, HttpContext httpContext)
         at Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Debug

I tested it that 'ODataApiVersionActionSelector' returns 4 candidates. But I don't know why.

I tried to debug, but it seems ApiVersioning 5.0 doesn't support the source link.

Would you please help to check? If you need to discuss it, I am available for a remote sync.
WebApplication1.zip

@commonsensesoftware
Copy link
Collaborator

Strange, SourceLink is definitely enabled and I've seen it work before. Unsure why debugging isn't working the way that it should:

image

The long story short is that everything about this repro is wrong:

  1. The wrong packages are being used
  2. The Microsoft.* packages do not have any support for net5.0, net6.0, or net7.0
    a. The fact that anyone got this far is a miracle
    b. The package info clearly indicates that the only officially supported TFM is netcoreapp3.1 (because of OData 7.x)
  3. OData 7.x is no longer supported (and zero effort will go into it by me)
    a. There is an unpublished 5.1.0 release, but I don't think it will help
    - You can thank MS and DNF as to why this isn't published (I'm exhausted after months of asking for help and promises)
    b. .NET Core 3.1 is EOL so there is little reason to support it
    - The latest 7.0.0 release drops support for it too, which was announced months ago
    c. I don't have the capacity to maintain multiple variants of OData (which has plagued me since the 5.x days)

Here is the repro you provided, echoed back with all the corrections and a few extra comments. The current set of OData examples demonstrate various configurations with OData 8.x. Even though the OData package doesn't list net7.0 as a supported TFM, it seems to work just fine.

I'm happy to provide any other insights, recommendations, or answer questions you may have. Happy holidays! 🎄 🎅🏽

@commonsensesoftware
Copy link
Collaborator

@HuntJason I can certainly appreciate your frustration and it's a lame place to be. To be clear, I run this project (and always have) by myself. I, nor this project, has ever been officially part of ASP.NET or OData. This is a very common misconception. I was at Microsoft for 14 years (which made it official MS OSS), but left almost 2 years ago. As the sole contributor and maintainer of this project, it has been incredibly infuriating to work through all the MS red tape. I've fallen on many grenades for the community, but - sadly - it has resulted in a somewhat Pyric Victory.

The biggest issue has been the requirement to switch package identifiers. I tried really hard to not do that. I originally had not planned to do that. I fought long and hard against it, but ultimately I was blocked on publishing, tired of waiting, and there was an opportunity to split up the packages going forward for the future and there was no way to keep it under the Microsoft naming/branding. I even considered forking the repo and starting anew. I followed the full process to transfer to the .NET Foundation and eventually became the co-owner of the old packages, but I still cannot publish any updates to them. I don't have plans to continue supporting them, but without the ability to publish, it's hard to let people know that there has been change (by way of release notes, etc). This is exactly what I was afraid would happen. I'm at my own wit's end of asking, begging, and even meeting F2F with people to make things right. The only thing I can really do is link to GitHub issues and let the community voice their opinion. 😞 At nearly 162M downloads, you'd think someone would be willing to help flush it all out.

I'm committed to being customer obsessed and doing what's right for the community. I've put up as many links and announcements as I can think of. If there is anything more you think I can do to help, I'm open to these suggestions. I hope this information is sufficient to unblock you. If not, feel free to ask questions.

@commonsensesoftware
Copy link
Collaborator

@xuzhg , @HuntJason, this issue appears to mostly be about some confusion on which packages and versions to use as well as the differences between them. Now that I've provided a clarification, provided a working example, and linked to additional examples, is there more to this issue or can I close it out?

@commonsensesoftware
Copy link
Collaborator

This issue has gone idle and as far as I can tell, it has been resolved. If you're still facing the issue feel free to ask more questions and/or reopen the issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants