Passing multiple id's in url returns single result, should return 404 Not Found
@KenitoInc is already working on this.
Since Nov 15, 2022.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
ASP.NET Core OData 8.x (master)
Describe the bug
When getting a single entity, but passing multiple ID's will return a single result (the first id found in the list). However, according to the specification this doesn't seem to be a valid url.
Reproduce steps
- Start the ODataRoutingSample
- Make a GET request to
http://localhost:5000/products(1,2,3)orhttp://localhost:5000/products(1)(2)(3) - The service returns a product with ID 1.
Data Model
Data model: https://github.com/OData/AspNetCoreOData/blob/9f1547e92a6bbed936dcae705491049014873be7/sample/ODataRoutingSample/Models/Product.cs#L12-L25
Controller: https://github.com/OData/AspNetCoreOData/blob/9f1547e92a6bbed936dcae705491049014873be7/sample/ODataRoutingSample/Controllers/ProductsController.cs#L74-L85
EDM (CSDL) Model
You probably know this EDM better than I do...
Request/Response
http://localhost:5000/> GET /products(1,2,3)
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8
Date: Tue, 15 Nov 2022 14:55:01 GMT
OData-Version: 4.0
Server: Kestrel
Transfer-Encoding: chunked
{
"@odata.context": "http://localhost:5000/$metadata#Products/$entity",
"Id": 1,
"Category": "Goods",
"Color": "Red",
"CreatedDate": 4/16/2001 2:24:08 AM,
"UpdatedDate": 2/16/2011 1:24:08 AM
}
Expected behavior
I would expect a 404 Not Found, since:
- I can't find an endpoint that accepts
1,2,3as a parameter - I can't find a product with the ID
1,2,3 - This is the default when not using OData
I could expect a 400 Bad Request, since the URL is not a valid OData URL, but Not Found seems to be more appropriate.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.