OData / odata.net

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

Suggestion: include declaring type in ODataWriter validation exceptions for properties #2960

Open syprieur opened 1 month ago

syprieur commented 1 month ago

OData does not place any restriction on name unicity for properties within the entire model. When working with large models, property names are often not unique (entirely distinct types may have properties with the same name).

The ODataWriter emits exception messages which only include the problematic property name, but not the declaring type. In large payloads with multiple nested scopes, it can be difficult for customers to find the problematic property value.

Suggestion: include the declaring type's full name in the exception message.

Assemblies affected

All Microsoft.OData.Core up to 7.21 included.

Reproduce steps

Using:

Provide the ODataWriter with a null value for that property.

Expected result

Error message including the declaring type name, such as: The property 'bar[Nullable=False]' of type 'Edm.String' declared by type 'microsoft.foo' has a null value, which is not allowed.

Actual result

Error message: The property 'bar[Nullable=False]' of type 'Edm.String' has a null value, which is not allowed.