Regression in v8.2.3
I have noticed the following issue with v8.2.3 while calling a OData function.
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Microsoft.OData.Client.ObjectMaterializerLog.CreatedInstance(MaterializerEntry entry)
at Microsoft.OData.Client.Materialization.EntryValueMaterializationPolicy.Materialize(MaterializerEntry entry, Type expectedEntryType, Boolean includeLinks)
at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.DirectMaterializePlan(ODataEntityMaterializer materializer, MaterializerEntry entry, Type expectedEntryType)
at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
at Microsoft.OData.Client.ObjectMaterializer.MoveNextInternal()
at Microsoft.OData.Client.ObjectMaterializer.MoveNext()
at System.Linq.Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext()
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
The issue can only be mitigated when downgraded to v8.1.0; that was the version, I was using previously; not sure exactly which version in between causes the issue. However, let me give you more details on this.
The OData action calls looks like this:
await ctx.Tenants
.Create(name, domain, contact, int1, int2, someFlag, anotherFlag)
.GetValueAsync()
The output of the OData action looks like this:
public class CreateTenantResult
{
public int Id { get; set; }
public IEnumerable<TenantProvisioningError> Errors { get; set; }
public CreateTenantResult(int id, IEnumerable<TenantProvisioningError> errors)
{
Id = id;
Errors = errors;
}
}
public class TenantProvisioningError
{
public string Name { get; set; }
public string Error { get; set; }
public string[] ErrorDetails { get; set; }
public TenantProvisioningError(string name, string error, string[] errorDetails = null)
{
Name = name;
Error = error;
ErrorDetails = errorDetails;
}
}
As I initially suspected an error from the server, I logged the response from the server.
Response STATUS: 200
Response HEADER Date: Thu, 06 Mar 2025 14:15:41 GMT
Response HEADER Connection: keep-alive
Response HEADER Server: Microsoft-HTTPAPI/2.0
Response HEADER OData-Version: 4.0
Response HEADER Content-Type: application/json; odata.metadata=minimal; charset=utf-8
Response HEADER Content-Length: 140
Response CONTENT: {
"@odata.context": "https://awesome.api/odata/v4/$metadata#NameSpace.CreateTenantResult",
"Id": 133,
"Errors": []
}
As can be seen from the log, the response from the log is ok. But immediately after that the OData client explodes with the error.
Maybe duplicate of #3124
We just encountered the same Issue. Will provide more information.
We are having the exact same problem and Stack Trace:
System.ArgumentNullException: Value cannot be null. (Parameter 'key') at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at Microsoft.OData.Client.ObjectMaterializerLog.CreatedInstance(MaterializerEntry entry) at Microsoft.OData.Client.Materialization.EntryValueMaterializationPolicy.Materialize(MaterializerEntry entry, Type expectedEntryType, Boolean includeLinks) at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.DirectMaterializePlan(ODataEntityMaterializer materializer, MaterializerEntry entry, Type expectedEntryType) at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation() at Microsoft.OData.Client.ObjectMaterializer.MoveNextInternal() at Microsoft.OData.Client.ObjectMaterializer.MoveNext()