NuGet Package: Microsoft.Azure.DocumentDB.Core (1.9.1)
Changing JsonSerializerSettings supplied to DocumentClient can cause StoredProc execution to fail.
Specifying TypeNameHandling.All causes multiple arguments to be passed as a _single object containing an array_, instead of as a _raw array_ when using the default serializer settings or TypeNameHandling.Auto.
As SerializerSettings are often specified for controlling how documents are formatted for storage in CosmosDB and typically not for how parameters are passed to CosmosDB StoredProcs - which should be consistent in all cases - this creates a fragile CosmosDB Client behaviour.
The output from the attached demo is:
TypeNameHandling.All arg count : 0 (Expected 3)
ScriptLog: undefined
TypeNameHandling.Auto arg count: 3 (Expected 3)
ScriptLog: arg1
Fiddler traces show parameters are passed as follows in the two scenarios:
TypeNameHandling.All: {"$type":"System.String[], System.Private.CoreLib","$values":["arg1","arg2","arg3"]}
TypeNameHandling.Auto (or default): ["arg1","arg2","arg3"]
We're also affected by this. It looks like the CosmosDB Client shouldn't use the provided SerializerSettings for StoredProc parameters, but it's own SerializerSettings instead.
Most helpful comment
We're also affected by this. It looks like the CosmosDB Client shouldn't use the provided SerializerSettings for StoredProc parameters, but it's own SerializerSettings instead.