Skip to content
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

ODataResourceDeserializerHelpers issues with ComplexTypes that have EdmModel navigation properties #2737

Closed
robertmclaws opened this issue Nov 23, 2022 · 0 comments · Fixed by #2744
Assignees
Labels

Comments

@robertmclaws
Copy link
Collaborator

robertmclaws commented Nov 23, 2022

Assemblies affected

ASP.NET Core OData 7.6.1

Describe the Problem

ODataResourceDeserializerHelpers.GenerateNestedReadContext() does not account for ComplexTypes (types that aren't mapped to the model) that contain properties whose types DO map to the model. At this point, edmProperty will not be null, and the edmProperty.PropertyKind will be Navigation, BUT readContext.Path.NavigationSource will be null, leading to a NullReferenceException on the next line.

(As an aside, the equality checks on lines 58 & 80 should be replaced with the "is" keyword, they evaluate faster. That should really be done throughout the codebase at some point.)

Reproduce steps

  1. Create an OData service with an endpoint that accepts a List<NotDatabaseObject> as a parameter.
  2. Make a request to that endpoint with multiple NotDatabaseObjects in the payload.

Data Model

public class DatabaseObject
{
     public Guid Id { get; set; }
}

public class NotDatabaseObject
{
    public List<DatabaseObject> DatabaseObjects { get; set; } = new();
}

Expected behavior

I expect the request to be processed like it was in previous versions and for the service to produce a response.

Screenshots
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants