odata.net icon indicating copy to clipboard operation
odata.net copied to clipboard

Allow ignoring errors, like collection is null from server response

Open johnwc opened this issue 1 year ago • 4 comments

There is quite a few oData services out in the wild that we are unable to connect to with these client libraries because they return the value null for properties marked as being a collection. Apparently even Microsoft's own software does this. In all realty, most developers could care less if a collection was returned as being null in the response. If the server does not respond with the property in the response at all, the collection is still null but no error is thrown.

We need to be able to tell the client to ignore this specific issue and not to throw an error when parsing the oData response. It stems from this method. https://github.com/OData/odata.net/blob/main/src/Microsoft.OData.Core/ReaderValidationUtils.cs#L1171

johnwc avatar Jul 03 '24 22:07 johnwc

@johnwc Look at this doc on how to omit null values from both the server side and client side: https://devblogs.microsoft.com/odata/extension-omit-null-value-properties-in-asp-net-core-odata/. Let me know if this helps.

ElizabethOkerio avatar Jul 04 '24 11:07 ElizabethOkerio

@johnwc Look at this doc on how to omit null values from both the server side and client side: https://devblogs.microsoft.com/odata/extension-omit-null-value-properties-in-asp-net-core-odata/. Let me know if this helps.

That does not do anything for client side to ignore anything, that example shows how to send a custom header to a custom server to tell the server to not return null values.

johnwc avatar Jul 05 '24 23:07 johnwc

As per the OData spec collections should not be null but can be empty that's why we validate this. But as @mikepizzo suggested to improve user experience, we can have an opt-in flag that ignores some of these validations.

ElizabethOkerio avatar Jul 10 '24 05:07 ElizabethOkerio

@ElizabethOkerio I did not see where @mikepizzo made that suggestion, can you share the link to that?

johnwc avatar Jul 15 '24 18:07 johnwc