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

ODataMessageReader doesn't honor the absence of ValidationKinds.ThrowIfTypeConflictsWithMetadata flag #1157

dozer75 opened this Issue May 2, 2018 · 0 comments


None yet
2 participants

dozer75 commented May 2, 2018

If a ODataMessageReader is created with settings where ValidationKinds.ThrowIfTypeConflictsWithMetadata flag isn't set in ODataMessageReaderSettings.Validations option it still checks for nulls (if configured by metadata) and fails.

Assemblies affected

Several versions of Microsoft.OData.Core including the latest one 7.4.4.

Reproduce steps

This gist shows the problem, create a .NET Core Console app, add this code and add the Microsoft.OData.Core nuget package to the project and run. Line 45 will throw an error even though it shouldn't since ODataMessageReaderSettings.Validations doesn't have the ValidationKinds.ThrowIfTypeConflictsWithMetadata flag set.

Expected result

When ODataMessageReaderSettings.Validations is missing the ValidationKinds.ThrowIfTypeConflictsWithMetadata flag no metadata checks should be done at all any places.

Actual result

An exception is thrown that states A null value was found for the property named 'Name', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.

Additional detail

The problem seems to be at this line, it should check for JsonLightInputContext.MessageReaderSettings.ThrowIfTypeConflictsWithMetadata too and everything works.

Frankly, really I don't see the point with the section starting with the link above, those checks are already done within ODataJsonReaderCoreUtils.TryReadNullValue anyway, so it seems to be unnecessary code. I tried to find out why this has been added but couldn't find it.

@AlanWong-MS AlanWong-MS added the P4 label May 2, 2018

@AlanWong-MS AlanWong-MS closed this May 3, 2018

@biaol-odata biaol-odata changed the title from ODataMessageReader doesn't honor the absense of ValidationKinds.ThrowIfTypeConflictsWithMetadata flag to ODataMessageReader doesn't honor the absence of ValidationKinds.ThrowIfTypeConflictsWithMetadata flag Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment