OData / odata.net

ODataLib: Open Data Protocol - .NET Libraries and Frameworks
https://docs.microsoft.com/odata
Other
686 stars 349 forks source link

Odata query doesn't return an error, incorrect #1896

Open MuhammadMujtaba19 opened 4 years ago

MuhammadMujtaba19 commented 4 years ago

I am using ODataURIParser to parse my Odata query sent from postman, I malformed a query by missing a equal to sign with the filter parameter. Surprisingly I didn't gave me the error I was expecting, instead it ignored that and returned me a output for that

Reproduce steps

Expected result

ODataURIParser should throw an error something like this

image

Note:- This is Odata's free Northwind service (https://services.odata.org/v4/Northwind/Northwind.svc)

Actual result

No error, Returns the output for https://localhost:9260/api/OData/Northwind/Customers and ignores the rest

image

Additional detail

this is not only problem with filter only, we can similarly send any malformed query, ODataURIParsers totally ignores them

xuzhg commented 4 years ago

https://github.com/OData/odata.net/blob/master/src/Microsoft.OData.Core/UriParser/ODataUriParser.cs#L232-L243

marabooy commented 4 years ago

@MuhammadMujtaba19 The library is currently written to be flexible enough to support custom query options with and without the $ sign which is currently not as per the protocol. In this case it would be a breaking change to raise the error from the Uriparser as there may be people who depend on this behavior. However the Northwind Sample Service does seem to have a bug which should throw an error for the un-used query options.

MuhammadMujtaba19 commented 3 years ago

@marabooy So, should I consider this as designed ?

marabooy commented 3 years ago

Currently the library works as designed but the sample has a bug which should be fixed,