Skip to content

Microsoft.OData.Core 8.4.3: in() with nullable enum and null throws The string 'null' is not a valid enumeration type constant. #3491

@lakshithaw99x

Description

@lakshithaw99x

After upgrading Microsoft.OData.Core from 8.4.2 to 8.4.3, queries using the in() operator on a nullable enum property fail when null is included in the value list.

This worked correctly in 8.4.2, but in 8.4.3 it throws:
Microsoft.OData.ODataException: The string 'null' is not a valid enumeration type constant.

Stack trace indicates the failure originates from enum constant validation logic inside:

MetadataBindingUtils.cs
The failure occurs specifically during:
queryOptions.Validate(validationSettings);

We assume this issue may be related to the recent flag enum support changes introduced in commit #3324

public enum Status
{
    New = 1,
    Active = 2,
    Closed = 3
}

public class Order
{
    public int Id { get; set; }

    // Nullable enum
    public Status? Status { get; set; }
}

Failing Url
GET https://localhost:5001/odata/Orders?$filter=Status in (null, 'Active')

Assemblies affected

Microsoft.OData.Core 8.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions