Compute generates duplicate endpoints for methods with no parameters

if you register a compute endpoint in your c# plugin, and it includes a method with no parameters, you will end up with two identical endpoints, and aspnetcore routing will fail with an AmbiguousMatchException

for example, if you register this class:

static class ComputeTest
{
    public static string TestEndpoint()
    {
        return "compute test ok";
    }
}

you will end up with these two listed at /sdk:

13926 [HTTP: POST computetest/testendpoint](http://localhost:5000/computetest/testendpoint)
13927 [HTTP: POST computetest/testendpoint](http://localhost:5000/computetest/testendpoint)

with any attempt to call resulting in:

Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:

HTTP: POST computetest/testendpoint
HTTP: POST computetest/testendpoint

so at least at first glance, it seems to me something like this is needed:

2 Likes

Thanks for reporting this. There was indeed a bug in the code. The bug occurred because the code was adding a general “catch all” endpoint for each method and then explicitly adding endpoints for all overloads, even if there were no parameters. This resulted in duplicate endpoints for methods without arguments. I’ve updated the method so that the general “catch all” endpoint is only added if there are multiple overloads for a method.
There should be a new build of Hops/Rhino.Compute. If you download the latest build of Hops (ver. 0.16.18) or pull down the repo from the 8.x branch, then this version of Rhino.Compute should work for you. Please let me know if that is not the case. Cheers.

2 Likes