-
Notifications
You must be signed in to change notification settings - Fork 161
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
Adding condition :min(1) to route parameter breaks OData routing #1352
Comments
Can you elaborate what exactly do you mean by "breaks OData routing"? Does it throw an exception when trying to access the endpoint? What is the status code? Can you share the output of the |
The endpoint is pushed into the Non-OData Endpoint Mappings in the :min(1) case The following is seen in the console: 'odata/global/SystemDataType/{id:int:min(1)}' on the action 'GetById' in controller 'SystemDataType' is not a valid OData path template. Bad Request - Error in query syntax. |
Ok, I can repro too. Definitely a bug, apparently caused by the presence of the parenthesis in the constraint, considering something like this still works fine: Even with a single constraint it also triggers the problem, so This feels to me like an opportunity to unify code between OData and ASPNET Core itself. Apparently, OData is not properly parsing Route Constraints here, meaning it is not using strong-enough abstractions to read the route template string. Error log is coming from here, on the attribute routing convention logic: AspNetCoreOData/src/Microsoft.AspNetCore.OData/Routing/Conventions/AttributeRoutingConvention.cs Lines 159 to 205 in 9a0c7db
But the actual exception is in |
Assemblies affected
.NET 9.0
Microsoft.AspNetCore.OData 9.1.0
Microsoft.OData.Core 8.21
Describe the bug
[ApiExplorerSettings(GroupName = "OData")]
[ODataRouteComponent("global")]
[Route("/odata/global")]
public class SystemDataTypeController(GlobalDbContext _db) : ODataController
{
[EnableQuery]
[HttpGet("SystemDataType")]
public IQueryable Get()
{
return _db.SystemDataTypes.AsNoTracking();
}
The text was updated successfully, but these errors were encountered: